MCPcopy
hub / github.com/tortoise/tortoise-orm / to_db_value

Method to_db_value

tortoise/fields/base.py:298–315  ·  view source on GitHub ↗

Converts from the Python type to the DB type. :param value: Current python value in model. :param instance: Model class or Model instance provided to look up. Due to metacoding, to determine if this is an instance reliably, please do a: .. code-blo

(self, value: Any, instance: type[Model] | Model)

Source from the content-addressed store, hash-verified

296 return result
297
298 def to_db_value(self, value: Any, instance: type[Model] | Model) -> Any:
299 """
300 Converts from the Python type to the DB type.
301
302 :param value: Current python value in model.
303 :param instance: Model class or Model instance provided to look up.
304
305 Due to metacoding, to determine if this is an instance reliably, please do a:
306
307 .. code-block:: py3
308
309 if hasattr(instance, "_saved_in_db"):
310 """
311 if value is not None and not isinstance(value, self.field_type):
312 value = self.field_type(value) # pylint: disable=E1102
313
314 self.validate(value)
315 return value
316
317 def to_python_value(self, value: Any) -> Any:
318 """

Callers 15

list_encoderFunction · 0.45
related_list_encoderFunction · 0.45
_process_filter_kwargMethod · 0.45
_make_queryMethod · 0.45
_make_queriesMethod · 0.45
_execute_manyMethod · 0.45
execute_insertMethod · 0.45
execute_updateMethod · 0.45
execute_deleteMethod · 0.45

Calls 1

validateMethod · 0.95

Tested by

no test coverage detected