fix isnull typo and formatting
This commit is contained in:
@ -20,8 +20,7 @@ to pydantic field types like ConstrainedStr
|
||||
#### is\_valid\_uni\_relation
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| is_valid_uni_relation(cls) -> bool
|
||||
| is_valid_uni_relation() -> bool
|
||||
```
|
||||
|
||||
Checks if field is a relation definition but only for ForeignKey relation,
|
||||
@ -40,8 +39,7 @@ Model columns only.
|
||||
#### get\_alias
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_alias(cls) -> str
|
||||
| get_alias() -> str
|
||||
```
|
||||
|
||||
Used to translate Model column names to database column names during db queries.
|
||||
@ -51,75 +49,26 @@ Used to translate Model column names to database column names during db queries.
|
||||
`(str)`: returns custom database column name if defined by user,
|
||||
otherwise field name in ormar/pydantic
|
||||
|
||||
<a name="fields.base.BaseField.is_valid_field_info_field"></a>
|
||||
#### is\_valid\_field\_info\_field
|
||||
<a name="fields.base.BaseField.get_pydantic_default"></a>
|
||||
#### get\_pydantic\_default
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| is_valid_field_info_field(cls, field_name: str) -> bool
|
||||
```
|
||||
|
||||
Checks if field belongs to pydantic FieldInfo
|
||||
- used during setting default pydantic values.
|
||||
Excludes defaults and alias as they are populated separately
|
||||
(defaults) or not at all (alias)
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `field_name (str)`: field name of BaseFIeld
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(bool)`: True if field is present on pydantic.FieldInfo
|
||||
|
||||
<a name="fields.base.BaseField.get_base_pydantic_field_info"></a>
|
||||
#### get\_base\_pydantic\_field\_info
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_base_pydantic_field_info(cls, allow_null: bool) -> FieldInfo
|
||||
| get_pydantic_default() -> Dict
|
||||
```
|
||||
|
||||
Generates base pydantic.FieldInfo with only default and optionally
|
||||
required to fix pydantic Json field being set to required=False.
|
||||
Used in an ormar Model Metaclass.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `allow_null (bool)`: flag if the default value can be None
|
||||
or if it should be populated by pydantic Undefined
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(pydantic.FieldInfo)`: instance of base pydantic.FieldInfo
|
||||
|
||||
<a name="fields.base.BaseField.convert_to_pydantic_field_info"></a>
|
||||
#### convert\_to\_pydantic\_field\_info
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| convert_to_pydantic_field_info(cls, allow_null: bool = False) -> FieldInfo
|
||||
```
|
||||
|
||||
Converts a BaseField into pydantic.FieldInfo
|
||||
that is later easily processed by pydantic.
|
||||
Used in an ormar Model Metaclass.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `allow_null (bool)`: flag if the default value can be None
|
||||
or if it should be populated by pydantic Undefined
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(pydantic.FieldInfo)`: actual instance of pydantic.FieldInfo with all needed fields populated
|
||||
|
||||
<a name="fields.base.BaseField.default_value"></a>
|
||||
#### default\_value
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| default_value(cls, use_server: bool = False) -> Optional[FieldInfo]
|
||||
| default_value(use_server: bool = False) -> Optional[Dict]
|
||||
```
|
||||
|
||||
Returns a FieldInfo instance with populated default
|
||||
@ -145,8 +94,7 @@ which is returning a FieldInfo instance
|
||||
#### get\_default
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_default(cls, use_server: bool = False) -> Any
|
||||
| get_default(use_server: bool = False) -> Any
|
||||
```
|
||||
|
||||
Return default value for a field.
|
||||
@ -166,8 +114,7 @@ treated as default value, default False
|
||||
#### has\_default
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| has_default(cls, use_server: bool = True) -> bool
|
||||
| has_default(use_server: bool = True) -> bool
|
||||
```
|
||||
|
||||
Checks if the field has default value set.
|
||||
@ -185,8 +132,7 @@ treated as default value, default False
|
||||
#### is\_auto\_primary\_key
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| is_auto_primary_key(cls) -> bool
|
||||
| is_auto_primary_key() -> bool
|
||||
```
|
||||
|
||||
Checks if field is first a primary key and if it,
|
||||
@ -201,8 +147,7 @@ Autoincrement primary_key is nullable/optional.
|
||||
#### construct\_constraints
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| construct_constraints(cls) -> List
|
||||
| construct_constraints() -> List
|
||||
```
|
||||
|
||||
Converts list of ormar constraints into sqlalchemy ForeignKeys.
|
||||
@ -217,8 +162,7 @@ And we need a new ForeignKey for subclasses of current model
|
||||
#### get\_column
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_column(cls, name: str) -> sqlalchemy.Column
|
||||
| get_column(name: str) -> sqlalchemy.Column
|
||||
```
|
||||
|
||||
Returns definition of sqlalchemy.Column used in creation of sqlalchemy.Table.
|
||||
@ -233,12 +177,28 @@ primary_key, index, unique, nullable, default and server_default.
|
||||
|
||||
`(sqlalchemy.Column)`: actual definition of the database column as sqlalchemy requires.
|
||||
|
||||
<a name="fields.base.BaseField._get_encrypted_column"></a>
|
||||
#### \_get\_encrypted\_column
|
||||
|
||||
```python
|
||||
| _get_encrypted_column(name: str) -> sqlalchemy.Column
|
||||
```
|
||||
|
||||
Returns EncryptedString column type instead of actual column.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `name (str)`: column name
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(sqlalchemy.Column)`: newly defined column
|
||||
|
||||
<a name="fields.base.BaseField.expand_relationship"></a>
|
||||
#### expand\_relationship
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| expand_relationship(cls, value: Any, child: Union["Model", "NewBaseModel"], to_register: bool = True) -> Any
|
||||
| expand_relationship(value: Any, child: Union["Model", "NewBaseModel"], to_register: bool = True) -> Any
|
||||
```
|
||||
|
||||
Function overwritten for relations, in basic field the value is returned as is.
|
||||
@ -261,8 +221,7 @@ dict (from Model) or actual instance/list of a "Model".
|
||||
#### set\_self\_reference\_flag
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| set_self_reference_flag(cls) -> None
|
||||
| set_self_reference_flag() -> None
|
||||
```
|
||||
|
||||
Sets `self_reference` to True if field to and owner are same model.
|
||||
@ -275,8 +234,7 @@ Sets `self_reference` to True if field to and owner are same model.
|
||||
#### has\_unresolved\_forward\_refs
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| has_unresolved_forward_refs(cls) -> bool
|
||||
| has_unresolved_forward_refs() -> bool
|
||||
```
|
||||
|
||||
Verifies if the filed has any ForwardRefs that require updating before the
|
||||
@ -290,8 +248,7 @@ model can be used.
|
||||
#### evaluate\_forward\_ref
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| evaluate_forward_ref(cls, globalns: Any, localns: Any) -> None
|
||||
| evaluate_forward_ref(globalns: Any, localns: Any) -> None
|
||||
```
|
||||
|
||||
Evaluates the ForwardRef to actual Field based on global and local namespaces
|
||||
@ -309,8 +266,7 @@ Evaluates the ForwardRef to actual Field based on global and local namespaces
|
||||
#### get\_related\_name
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_related_name(cls) -> str
|
||||
| get_related_name() -> str
|
||||
```
|
||||
|
||||
Returns name to use for reverse relation.
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#### create\_dummy\_instance
|
||||
|
||||
```python
|
||||
create_dummy_instance(fk: Type["Model"], pk: Any = None) -> "Model"
|
||||
create_dummy_instance(fk: Type["T"], pk: Any = None) -> "T"
|
||||
```
|
||||
|
||||
Ormar never returns you a raw data.
|
||||
@ -31,7 +31,7 @@ If the nested related Models are required they are set with -1 as pk value.
|
||||
#### create\_dummy\_model
|
||||
|
||||
```python
|
||||
create_dummy_model(base_model: Type["Model"], pk_field: Type[Union[BaseField, "ForeignKeyField", "ManyToManyField"]]) -> Type["BaseModel"]
|
||||
create_dummy_model(base_model: Type["T"], pk_field: Union[BaseField, "ForeignKeyField", "ManyToManyField"]) -> Type["BaseModel"]
|
||||
```
|
||||
|
||||
Used to construct a dummy pydantic model for type hints and pydantic validation.
|
||||
@ -40,7 +40,7 @@ Populates only pk field and set it to desired type.
|
||||
**Arguments**:
|
||||
|
||||
- `base_model (Model class)`: class of target dummy model
|
||||
- `pk_field (Type[Union[BaseField, "ForeignKeyField", "ManyToManyField"]])`: ormar Field to be set on pydantic Model
|
||||
- `pk_field (Union[BaseField, "ForeignKeyField", "ManyToManyField"])`: ormar Field to be set on pydantic Model
|
||||
|
||||
**Returns**:
|
||||
|
||||
@ -50,7 +50,7 @@ Populates only pk field and set it to desired type.
|
||||
#### populate\_fk\_params\_based\_on\_to\_model
|
||||
|
||||
```python
|
||||
populate_fk_params_based_on_to_model(to: Type["Model"], nullable: bool, onupdate: str = None, ondelete: str = None) -> Tuple[Any, List, Any]
|
||||
populate_fk_params_based_on_to_model(to: Type["T"], nullable: bool, onupdate: str = None, ondelete: str = None) -> Tuple[Any, List, Any]
|
||||
```
|
||||
|
||||
Based on target to model to which relation leads to populates the type of the
|
||||
@ -69,6 +69,25 @@ How to treat child rows on delete of parent (the one where FK is defined) model.
|
||||
|
||||
`(Tuple[Any, List, Any])`: tuple with target pydantic type, list of fk constraints and target col type
|
||||
|
||||
<a name="fields.foreign_key.validate_not_allowed_fields"></a>
|
||||
#### validate\_not\_allowed\_fields
|
||||
|
||||
```python
|
||||
validate_not_allowed_fields(kwargs: Dict) -> None
|
||||
```
|
||||
|
||||
Verifies if not allowed parameters are set on relation models.
|
||||
Usually they are omitted later anyway but this way it's explicitly
|
||||
notify the user that it's not allowed/ supported.
|
||||
|
||||
**Raises**:
|
||||
|
||||
- `ModelDefinitionError`: if any forbidden field is set
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Dict)`: dict of kwargs to verify passed to relation field
|
||||
|
||||
<a name="fields.foreign_key.UniqueColumns"></a>
|
||||
## UniqueColumns Objects
|
||||
|
||||
@ -94,7 +113,7 @@ to produce sqlalchemy.ForeignKeys
|
||||
#### ForeignKey
|
||||
|
||||
```python
|
||||
ForeignKey(to: "ToType", *, name: str = None, unique: bool = False, nullable: bool = True, related_name: str = None, virtual: bool = False, onupdate: str = None, ondelete: str = None, **kwargs: Any, ,) -> Any
|
||||
ForeignKey(to: "ToType", *, name: str = None, unique: bool = False, nullable: bool = True, related_name: str = None, virtual: bool = False, onupdate: str = None, ondelete: str = None, **kwargs: Any, ,) -> "T"
|
||||
```
|
||||
|
||||
Despite a name it's a function that returns constructed ForeignKeyField.
|
||||
@ -134,8 +153,7 @@ Actual class returned from ForeignKey function call and stored in model_fields.
|
||||
#### get\_source\_related\_name
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_source_related_name(cls) -> str
|
||||
| get_source_related_name() -> str
|
||||
```
|
||||
|
||||
Returns name to use for source relation name.
|
||||
@ -150,8 +168,7 @@ It's either set as `related_name` or by default it's owner model. get_name + 's'
|
||||
#### get\_related\_name
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_related_name(cls) -> str
|
||||
| get_related_name() -> str
|
||||
```
|
||||
|
||||
Returns name to use for reverse relation.
|
||||
@ -161,12 +178,37 @@ It's either set as `related_name` or by default it's owner model. get_name + 's'
|
||||
|
||||
`(str)`: name of the related_name or default related name.
|
||||
|
||||
<a name="fields.foreign_key.ForeignKeyField.default_target_field_name"></a>
|
||||
#### default\_target\_field\_name
|
||||
|
||||
```python
|
||||
| default_target_field_name() -> str
|
||||
```
|
||||
|
||||
Returns default target model name on through model.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(str)`: name of the field
|
||||
|
||||
<a name="fields.foreign_key.ForeignKeyField.default_source_field_name"></a>
|
||||
#### default\_source\_field\_name
|
||||
|
||||
```python
|
||||
| default_source_field_name() -> str
|
||||
```
|
||||
|
||||
Returns default target model name on through model.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(str)`: name of the field
|
||||
|
||||
<a name="fields.foreign_key.ForeignKeyField.evaluate_forward_ref"></a>
|
||||
#### evaluate\_forward\_ref
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| evaluate_forward_ref(cls, globalns: Any, localns: Any) -> None
|
||||
| evaluate_forward_ref(globalns: Any, localns: Any) -> None
|
||||
```
|
||||
|
||||
Evaluates the ForwardRef to actual Field based on global and local namespaces
|
||||
@ -184,8 +226,7 @@ Evaluates the ForwardRef to actual Field based on global and local namespaces
|
||||
#### \_extract\_model\_from\_sequence
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| _extract_model_from_sequence(cls, value: List, child: "Model", to_register: bool) -> List["Model"]
|
||||
| _extract_model_from_sequence(value: List, child: "Model", to_register: bool) -> List["Model"]
|
||||
```
|
||||
|
||||
Takes a list of Models and registers them on parent.
|
||||
@ -207,8 +248,7 @@ Used in reverse FK relations.
|
||||
#### \_register\_existing\_model
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| _register_existing_model(cls, value: "Model", child: "Model", to_register: bool) -> "Model"
|
||||
| _register_existing_model(value: "Model", child: "Model", to_register: bool) -> "Model"
|
||||
```
|
||||
|
||||
Takes already created instance and registers it for parent.
|
||||
@ -230,8 +270,7 @@ Used in reverse FK relations and normal FK for single models.
|
||||
#### \_construct\_model\_from\_dict
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| _construct_model_from_dict(cls, value: dict, child: "Model", to_register: bool) -> "Model"
|
||||
| _construct_model_from_dict(value: dict, child: "Model", to_register: bool) -> "Model"
|
||||
```
|
||||
|
||||
Takes a dictionary, creates a instance and registers it for parent.
|
||||
@ -254,8 +293,7 @@ Used in normal FK for dictionaries.
|
||||
#### \_construct\_model\_from\_pk
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| _construct_model_from_pk(cls, value: Any, child: "Model", to_register: bool) -> "Model"
|
||||
| _construct_model_from_pk(value: Any, child: "Model", to_register: bool) -> "Model"
|
||||
```
|
||||
|
||||
Takes a pk value, creates a dummy instance and registers it for parent.
|
||||
@ -277,8 +315,7 @@ Used in normal FK for dictionaries.
|
||||
#### register\_relation
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| register_relation(cls, model: "Model", child: "Model") -> None
|
||||
| register_relation(model: "Model", child: "Model") -> None
|
||||
```
|
||||
|
||||
Registers relation between parent and child in relation manager.
|
||||
@ -296,8 +333,7 @@ Used in Metaclass and sometimes some relations are missing
|
||||
#### has\_unresolved\_forward\_refs
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| has_unresolved_forward_refs(cls) -> bool
|
||||
| has_unresolved_forward_refs() -> bool
|
||||
```
|
||||
|
||||
Verifies if the filed has any ForwardRefs that require updating before the
|
||||
@ -311,8 +347,7 @@ model can be used.
|
||||
#### expand\_relationship
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| expand_relationship(cls, value: Any, child: Union["Model", "NewBaseModel"], to_register: bool = True) -> Optional[Union["Model", List["Model"]]]
|
||||
| expand_relationship(value: Any, child: Union["Model", "NewBaseModel"], to_register: bool = True) -> Optional[Union["Model", List["Model"]]]
|
||||
```
|
||||
|
||||
For relations the child model is first constructed (if needed),
|
||||
@ -336,8 +371,7 @@ Selects the appropriate constructor based on a passed value.
|
||||
#### get\_relation\_name
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_relation_name(cls) -> str
|
||||
| get_relation_name() -> str
|
||||
```
|
||||
|
||||
Returns name of the relation, which can be a own name or through model
|
||||
@ -351,8 +385,7 @@ names for m2m models
|
||||
#### get\_source\_model
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_source_model(cls) -> Type["Model"]
|
||||
| get_source_model() -> Type["Model"]
|
||||
```
|
||||
|
||||
Returns model from which the relation comes -> either owner or through model
|
||||
|
||||
@ -1,6 +1,19 @@
|
||||
<a name="fields.many_to_many"></a>
|
||||
# fields.many\_to\_many
|
||||
|
||||
<a name="fields.many_to_many.forbid_through_relations"></a>
|
||||
#### forbid\_through\_relations
|
||||
|
||||
```python
|
||||
forbid_through_relations(through: Type["Model"]) -> None
|
||||
```
|
||||
|
||||
Verifies if the through model does not have relations.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `through (Type['Model])`: through Model to be checked
|
||||
|
||||
<a name="fields.many_to_many.populate_m2m_params_based_on_to_model"></a>
|
||||
#### populate\_m2m\_params\_based\_on\_to\_model
|
||||
|
||||
@ -24,7 +37,7 @@ pydantic field to use and type of the target column field.
|
||||
#### ManyToMany
|
||||
|
||||
```python
|
||||
ManyToMany(to: "ToType", through: Optional["ToType"] = None, *, name: str = None, unique: bool = False, virtual: bool = False, **kwargs: Any, ,) -> Any
|
||||
ManyToMany(to: "ToType", through: Optional["ToType"] = None, *, name: str = None, unique: bool = False, virtual: bool = False, **kwargs: Any, ,) -> "RelationProxy[T]"
|
||||
```
|
||||
|
||||
Despite a name it's a function that returns constructed ManyToManyField.
|
||||
@ -60,8 +73,7 @@ Actual class returned from ManyToMany function call and stored in model_fields.
|
||||
#### get\_source\_related\_name
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_source_related_name(cls) -> str
|
||||
| get_source_related_name() -> str
|
||||
```
|
||||
|
||||
Returns name to use for source relation name.
|
||||
@ -72,40 +84,11 @@ It's either set as `related_name` or by default it's field name.
|
||||
|
||||
`(str)`: name of the related_name or default related name.
|
||||
|
||||
<a name="fields.many_to_many.ManyToManyField.default_target_field_name"></a>
|
||||
#### default\_target\_field\_name
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| default_target_field_name(cls) -> str
|
||||
```
|
||||
|
||||
Returns default target model name on through model.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(str)`: name of the field
|
||||
|
||||
<a name="fields.many_to_many.ManyToManyField.default_source_field_name"></a>
|
||||
#### default\_source\_field\_name
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| default_source_field_name(cls) -> str
|
||||
```
|
||||
|
||||
Returns default target model name on through model.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(str)`: name of the field
|
||||
|
||||
<a name="fields.many_to_many.ManyToManyField.has_unresolved_forward_refs"></a>
|
||||
#### has\_unresolved\_forward\_refs
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| has_unresolved_forward_refs(cls) -> bool
|
||||
| has_unresolved_forward_refs() -> bool
|
||||
```
|
||||
|
||||
Verifies if the filed has any ForwardRefs that require updating before the
|
||||
@ -119,8 +102,7 @@ model can be used.
|
||||
#### evaluate\_forward\_ref
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| evaluate_forward_ref(cls, globalns: Any, localns: Any) -> None
|
||||
| evaluate_forward_ref(globalns: Any, localns: Any) -> None
|
||||
```
|
||||
|
||||
Evaluates the ForwardRef to actual Field based on global and local namespaces
|
||||
@ -138,8 +120,7 @@ Evaluates the ForwardRef to actual Field based on global and local namespaces
|
||||
#### get\_relation\_name
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_relation_name(cls) -> str
|
||||
| get_relation_name() -> str
|
||||
```
|
||||
|
||||
Returns name of the relation, which can be a own name or through model
|
||||
@ -153,8 +134,7 @@ names for m2m models
|
||||
#### get\_source\_model
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| get_source_model(cls) -> Type["Model"]
|
||||
| get_source_model() -> Type["Model"]
|
||||
```
|
||||
|
||||
Returns model from which the relation comes -> either owner or through model
|
||||
@ -167,8 +147,7 @@ Returns model from which the relation comes -> either owner or through model
|
||||
#### create\_default\_through\_model
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| create_default_through_model(cls) -> None
|
||||
| create_default_through_model() -> None
|
||||
```
|
||||
|
||||
Creates default empty through model if no additional fields are required.
|
||||
|
||||
Reference in New Issue
Block a user