BaseField
class¶
edgy.core.db.fields.base.BaseField
¶
BaseField(*, default=Undefined, **kwargs)
Bases: BaseFieldType
, FieldInfo
The base field for Edgy data model fields. It provides some helpers additional to BaseFieldType and inherits from FieldInfo for pydantic integration.
Allows factories to overwrite methods.
Source code in edgy/core/db/fields/base.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
operator_mapping
class-attribute
instance-attribute
¶
operator_mapping = {'is': 'is_', 'in': 'in_', 'exact': '__eq__', 'not': '__ne__', 'gt': '__gt__', 'ge': '__ge__', 'gte': '__ge__', 'lt': '__lt__', 'lte': '__le__', 'le': '__le__'}
auto_compute_server_default
class-attribute
instance-attribute
¶
auto_compute_server_default = False
server_default
instance-attribute
¶
server_default = customize_default_for_server_default(self, default, original_fn=customize_default_for_server_default)
inject_default_on_partial_update
class-attribute
instance-attribute
¶
inject_default_on_partial_update = False
customize_default_for_server_default
¶
customize_default_for_server_default(default)
Source code in edgy/core/db/fields/base.py
120 121 122 123 |
|
get_columns_nullable
¶
get_columns_nullable()
Helper method. Returns if the columns of the field should be nullable.
Source code in edgy/core/db/fields/base.py
125 126 127 128 129 130 131 132 133 |
|
operator_to_clause
¶
operator_to_clause(field_name, operator, table, value)
Base implementation, adaptable
Source code in edgy/core/db/fields/base.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
is_required
¶
is_required()
Check if the argument is required.
RETURNS | DESCRIPTION |
---|---|
bool
|
|
Source code in edgy/core/db/fields/base.py
165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
has_default
¶
has_default()
Checks if the field has a default value set
Source code in edgy/core/db/fields/base.py
179 180 181 182 183 |
|
get_columns
¶
get_columns(name)
Returns the columns of the field being declared.
Source code in edgy/core/db/fields/base.py
185 186 187 188 189 |
|
embed_field
¶
embed_field(prefix, new_fieldname, owner=None, parent=None)
Embed this field or return None to prevent embedding. Must return a copy with name and owner set when not returning None.
Source code in edgy/core/db/fields/base.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
get_default_value
¶
get_default_value()
Source code in edgy/core/db/fields/base.py
215 216 217 218 219 220 |
|
get_default_values
¶
get_default_values(field_name, cleaned_data)
Source code in edgy/core/db/fields/base.py
222 223 224 225 226 227 228 229 |
|
clean
¶
clean(field_name, value, for_query=False)
Validates a value and transform it into columns which can be used for querying and saving.
PARAMETER | DESCRIPTION |
---|---|
field_name
|
the field name (can be different from name)
TYPE:
|
value
|
the field value
TYPE:
|
Kwargs: for_query: Is used for querying. Should have all columns used for querying set. The columns used can differ especially for multi column fields.
Source code in edgy/core/db/fields/types.py
111 112 113 114 115 116 117 118 119 120 121 122 |
|
to_model
¶
to_model(field_name, value)
Inverse of clean. Transforms column(s) to a field for edgy.Model. Validation happens later.
PARAMETER | DESCRIPTION |
---|---|
field_name
|
the field name (can be different from name)
TYPE:
|
value
|
the field value
TYPE:
|
Source code in edgy/core/db/fields/types.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
get_global_constraints
¶
get_global_constraints(name, columns, schemes=())
Return global constraints and indexes. Useful for multicolumn fields
Source code in edgy/core/db/fields/types.py
139 140 141 142 143 144 145 146 147 148 |
|
get_embedded_fields
¶
get_embedded_fields(field_name, fields)
Define extra fields on the fly. Often no owner is available yet.
PARAMETER | DESCRIPTION |
---|---|
field_name
|
the field name (can be different from name)
TYPE:
|
fields
|
the existing fields
TYPE:
|
the returned fields are changed after return, so you should
return new fields or copies. Also set the owner of the field to them before returning
Source code in edgy/core/db/fields/types.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
get_column_names
¶
get_column_names(name='')
Source code in edgy/core/db/fields/types.py
217 218 219 220 |
|