BaseField
class¶
edgy.core.db.fields.base.BaseField
¶
BaseField(*, default=Undefined, server_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 |
|
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
inject_default_on_partial_update
class-attribute
instance-attribute
¶
inject_default_on_partial_update = False
get_server_default
¶
get_server_default()
Retrieve the server_default.
Source code in edgy/core/db/fields/base.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
customize_default_for_server_default
¶
customize_default_for_server_default(default)
Modify default for non-null server_default.
PARAMETER | DESCRIPTION |
---|---|
default
|
The original default.
TYPE:
|
Source code in edgy/core/db/fields/base.py
122 123 124 125 126 127 128 129 130 131 132 |
|
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
134 135 136 137 138 139 140 141 142 |
|
operator_to_clause
¶
operator_to_clause(field_name, operator, table, value)
Base implementation, adaptable
Source code in edgy/core/db/fields/base.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
is_required
¶
is_required()
Check if the argument is required.
RETURNS | DESCRIPTION |
---|---|
bool
|
|
Source code in edgy/core/db/fields/base.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
has_default
¶
has_default()
Checks if the field has a default value set
Source code in edgy/core/db/fields/base.py
189 190 191 192 193 |
|
get_columns
¶
get_columns(name)
Returns the columns of the field being declared.
Source code in edgy/core/db/fields/base.py
195 196 197 198 199 |
|
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
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
get_default_value
¶
get_default_value()
Source code in edgy/core/db/fields/base.py
225 226 227 228 229 230 |
|
get_default_values
¶
get_default_values(field_name, cleaned_data)
Source code in edgy/core/db/fields/base.py
232 233 234 235 236 237 238 239 |
|
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
112 113 114 115 116 117 118 119 120 121 122 123 |
|
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
125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
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
140 141 142 143 144 145 146 147 148 149 |
|
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
151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
get_column_names
¶
get_column_names(name='')
Source code in edgy/core/db/fields/types.py
207 208 209 210 |
|