Base Field type. :param source_field: Provide a source_field name if the DB column name needs to be something specific instead of generated off the field name. :param generated: Is this field DB-generated? :param primary_key: Is this field a Primary Key? Can only have a sin
| 102 | |
| 103 | |
| 104 | class Field(Generic[VALUE], metaclass=_FieldMeta): |
| 105 | """ |
| 106 | Base Field type. |
| 107 | |
| 108 | :param source_field: Provide a source_field name if the DB column name needs to be |
| 109 | something specific instead of generated off the field name. |
| 110 | :param generated: Is this field DB-generated? |
| 111 | :param primary_key: Is this field a Primary Key? Can only have a single such field on the Model, |
| 112 | and if none is specified it will autogenerate a default primary key called ``id``. |
| 113 | :param null: Is this field nullable? |
| 114 | :param default: A default value for the field if not specified on Model creation. |
| 115 | This can also be a callable for dynamic defaults in which case we will call it. |
| 116 | The default value will not be part of the schema. |
| 117 | :param db_default: A database-level default value. This can be a static value or an |
| 118 | instance of :class:`~tortoise.fields.db_defaults.SqlDefault` |
| 119 | :param unique: Is this field unique? |
| 120 | :param db_index: Should this field be indexed by itself? |
| 121 | :param description: Field description. Will also appear in ``Tortoise.describe_model()`` |
| 122 | and as DB comments in the generated DDL. |
| 123 | :param validators: Validators for this field. |
| 124 | |
| 125 | **Class Attributes:** |
| 126 | These attributes needs to be defined when defining an actual field type. |
| 127 | |
| 128 | .. attribute:: field_type |
| 129 | :annotation: type[Any] |
| 130 | |
| 131 | The Python type the field is. |
| 132 | If adding a type as a mixin, _FieldMeta will automatically set this to that. |
| 133 | |
| 134 | .. attribute:: indexable |
| 135 | :annotation: bool = True |
| 136 | |
| 137 | Is the field indexable? Set to False if this field can't be indexed reliably. |
| 138 | |
| 139 | .. attribute:: has_db_field |
| 140 | :annotation: bool = True |
| 141 | |
| 142 | Does this field have a direct corresponding DB column? Or is the field virtualized? |
| 143 | |
| 144 | .. attribute:: skip_to_python_if_native |
| 145 | :annotation: bool = False |
| 146 | |
| 147 | If the DB driver natively supports this Python type, should we skip it? |
| 148 | This is for optimization purposes only, where we don't need to force type conversion |
| 149 | between Python and the DB. |
| 150 | |
| 151 | .. attribute:: allows_generated |
| 152 | :annotation: bool = False |
| 153 | |
| 154 | Is this field able to be DB-generated? |
| 155 | |
| 156 | .. attribute:: function_cast |
| 157 | :annotation: Optional[pypika_tortoise.Term] = None |
| 158 | |
| 159 | A casting term that we need to apply in case the DB needs emulation help. |
| 160 | |
| 161 | .. attribute:: SQL_TYPE |
no outgoing calls
searching dependent graphs…