MCPcopy Index your code
hub / github.com/tortoise/tortoise-orm / to_db_value

Method to_db_value

tests/fields/subclass_fields.py:59–67  ·  view source on GitHub ↗
(self, value: Any, instance)

Source from the content-addressed store, hash-verified

57 self.enum_type = enum_type
58
59 def to_db_value(self, value: Any, instance) -> Any:
60 self.validate(value)
61
62 if value is None:
63 return value
64 if not isinstance(value, self.enum_type):
65 raise TypeError(f"Expected type {self.enum_type}, got {value}")
66
67 return value.value
68
69 def to_python_value(self, value: Any) -> Any:
70 if value is None or isinstance(value, self.enum_type):

Callers

nothing calls this directly

Calls 1

validateMethod · 0.80

Tested by

no test coverage detected