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.
PARAMETER | DESCRIPTION |
---|---|
default |
TYPE:
|
**kwargs |
TYPE:
|
Source code in edgy/core/db/fields/base.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
inject_default_on_partial_update
class-attribute
instance-attribute
¶
inject_default_on_partial_update = False
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__'}
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 |
TYPE:
|
value |
TYPE:
|
for_query |
TYPE:
|
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
103 104 105 106 107 108 109 110 111 112 113 114 |
|
to_model
¶
to_model(field_name, value)
Inverse of clean. Transforms column(s) to a field for a pydantic model (EdgyBaseModel). Validation happens later.
PARAMETER | DESCRIPTION |
---|---|
field_name |
TYPE:
|
value |
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
field_name |
the field name (can be different from name)
TYPE:
|
value |
the field value
TYPE:
|
Kwargs: phase: the phase (set, creation, ...)
Source code in edgy/core/db/fields/types.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
get_global_constraints
¶
get_global_constraints(name, columns, schemes=())
Return global constraints and indexes. Useful for multicolumn fields
PARAMETER | DESCRIPTION |
---|---|
name |
TYPE:
|
columns |
TYPE:
|
schemes |
TYPE:
|
Source code in edgy/core/db/fields/types.py
134 135 136 137 138 139 140 |
|
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 |
TYPE:
|
fields |
TYPE:
|
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
142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
get_column_names
¶
get_column_names(name='')
PARAMETER | DESCRIPTION |
---|---|
name |
TYPE:
|
Source code in edgy/core/db/fields/types.py
198 199 200 201 |
|
operator_to_clause
¶
operator_to_clause(field_name, operator, table, value)
Base implementation, adaptable
PARAMETER | DESCRIPTION |
---|---|
field_name |
TYPE:
|
operator |
TYPE:
|
table |
TYPE:
|
value |
TYPE:
|
Source code in edgy/core/db/fields/base.py
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 |
|
is_required
¶
is_required()
Check if the argument is required.
RETURNS | DESCRIPTION |
---|---|
bool
|
|
Source code in edgy/core/db/fields/base.py
117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
has_default
¶
has_default()
Checks if the field has a default value set
Source code in edgy/core/db/fields/base.py
131 132 133 134 135 |
|
get_columns
¶
get_columns(name)
Returns the columns of the field being declared.
PARAMETER | DESCRIPTION |
---|---|
name |
TYPE:
|
Source code in edgy/core/db/fields/base.py
137 138 139 140 141 |
|
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.
PARAMETER | DESCRIPTION |
---|---|
prefix |
TYPE:
|
new_fieldname |
TYPE:
|
owner |
TYPE:
|
parent |
TYPE:
|
Source code in edgy/core/db/fields/base.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
get_default_value
¶
get_default_value()
Source code in edgy/core/db/fields/base.py
159 160 161 162 163 164 |
|
get_default_values
¶
get_default_values(field_name, cleaned_data)
PARAMETER | DESCRIPTION |
---|---|
field_name |
TYPE:
|
cleaned_data |
TYPE:
|
Source code in edgy/core/db/fields/base.py
166 167 168 169 170 171 172 173 |
|