MCPcopy Create free account
hub / github.com/tortoise/tortoise-orm / CharEnumField

Function CharEnumField

tortoise/fields/data.py:981–1009  ·  view source on GitHub ↗

Char Enum Field A field representing a character enumeration. **Warning**: If ``max_length`` is not specified or equals to zero, the size of represented char fields is automatically detected. So if later you update the enum, you need to update your table schema as well. *

(
    enum_type: type[CharEnumType],
    description: str | None = None,
    max_length: int = 0,
    **kwargs: Any,
)

Source from the content-addressed store, hash-verified

979
980
981def CharEnumField(
982 enum_type: type[CharEnumType],
983 description: str | None = None,
984 max_length: int = 0,
985 **kwargs: Any,
986) -> CharEnumType:
987 """
988 Char Enum Field
989
990 A field representing a character enumeration.
991
992 **Warning**: If ``max_length`` is not specified or equals to zero, the size of represented
993 char fields is automatically detected. So if later you update the enum, you need to update your
994 table schema as well.
995
996 **Note**: Valid str value of ``enum_type`` is acceptable.
997
998 ``enum_type``:
999 The enum class
1000 ``description``:
1001 The description of the field. It is set automatically if not specified to a multiline list
1002 of "name: value" pairs.
1003 ``max_length``:
1004 The length of the created CharField. If it is zero it is automatically detected from
1005 enum_type.
1006
1007 """
1008
1009 return CharEnumFieldInstance(enum_type, description, max_length, **kwargs) # type: ignore

Calls 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…