This commit is contained in:
collerek
2021-06-08 14:34:02 +02:00
parent a1557273b0
commit 96c9615229
49 changed files with 1917 additions and 994 deletions

View File

@ -15,7 +15,7 @@ Sets pydantic fields with child and parent model types.
**Arguments**:
- `model_field (ManyToManyField)`: relation field defined in parent model
- `model_field` (`ManyToManyField`): relation field defined in parent model
<a name="models.helpers.sqlalchemy.create_and_append_m2m_fk"></a>
#### create\_and\_append\_m2m\_fk
@ -30,9 +30,9 @@ Newly created field is added to m2m relation through model Meta columns and tabl
**Arguments**:
- `field_name (str)`: name of the column to create
- `model (Model class)`: Model class to which FK should be created
- `model_field (ManyToManyField field)`: field with ManyToMany relation
- `field_name` (`str`): name of the column to create
- `model` (`Model class`): Model class to which FK should be created
- `model_field` (`ManyToManyField field`): field with ManyToMany relation
<a name="models.helpers.sqlalchemy.check_pk_column_validity"></a>
#### check\_pk\_column\_validity
@ -51,13 +51,13 @@ as pydantic_only as it needs to be a database field.
**Arguments**:
- `field_name (str)`: name of field
- `field (BaseField)`: ormar.Field
- `pkname (Optional[str])`: already set pkname
- `field_name` (`str`): name of field
- `field` (`BaseField`): ormar.Field
- `pkname` (`Optional[str]`): already set pkname
**Returns**:
`(str)`: name of the field that should be set as pkname
`str`: name of the field that should be set as pkname
<a name="models.helpers.sqlalchemy.sqlalchemy_columns_from_model_fields"></a>
#### sqlalchemy\_columns\_from\_model\_fields
@ -91,12 +91,12 @@ or pkname validation fails.
**Arguments**:
- `model_fields (Dict[str, ormar.Field])`: dictionary of declared ormar model fields
- `new_model (Model class)`:
- `model_fields` (`Dict[str, ormar.Field]`): dictionary of declared ormar model fields
- `new_model` (`Model class`):
**Returns**:
`(Tuple[Optional[str], List[sqlalchemy.Column]])`: pkname, list of sqlalchemy columns
`Tuple[Optional[str], List[sqlalchemy.Column]]`: pkname, list of sqlalchemy columns
<a name="models.helpers.sqlalchemy._process_fields"></a>
#### \_process\_fields
@ -123,12 +123,12 @@ or pkname validation fails.
**Arguments**:
- `model_fields (Dict[str, ormar.Field])`: dictionary of declared ormar model fields
- `new_model (Model class)`:
- `model_fields` (`Dict[str, ormar.Field]`): dictionary of declared ormar model fields
- `new_model` (`Model class`):
**Returns**:
`(Tuple[Optional[str], List[sqlalchemy.Column]])`: pkname, list of sqlalchemy columns
`Tuple[Optional[str], List[sqlalchemy.Column]]`: pkname, list of sqlalchemy columns
<a name="models.helpers.sqlalchemy._is_through_model_not_set"></a>
#### \_is\_through\_model\_not\_set
@ -141,11 +141,11 @@ Alias to if check that verifies if through model was created.
**Arguments**:
- `field ("BaseField")`: field to check
- `field` (`"BaseField"`): field to check
**Returns**:
`(bool)`: result of the check
`bool`: result of the check
<a name="models.helpers.sqlalchemy._is_db_field"></a>
#### \_is\_db\_field
@ -158,11 +158,11 @@ Alias to if check that verifies if field should be included in database.
**Arguments**:
- `field ("BaseField")`: field to check
- `field` (`"BaseField"`): field to check
**Returns**:
`(bool)`: result of the check
`bool`: result of the check
<a name="models.helpers.sqlalchemy.populate_meta_tablename_columns_and_pk"></a>
#### populate\_meta\_tablename\_columns\_and\_pk
@ -185,12 +185,12 @@ Each model has to have pk.
**Arguments**:
- `name (str)`: name of the current Model
- `new_model (ormar.models.metaclass.ModelMetaclass)`: currently constructed Model
- `name` (`str`): name of the current Model
- `new_model` (`ormar.models.metaclass.ModelMetaclass`): currently constructed Model
**Returns**:
`(ormar.models.metaclass.ModelMetaclass)`: Model with populated pkname and columns in Meta
`ormar.models.metaclass.ModelMetaclass`: Model with populated pkname and columns in Meta
<a name="models.helpers.sqlalchemy.check_for_null_type_columns_from_forward_refs"></a>
#### check\_for\_null\_type\_columns\_from\_forward\_refs
@ -203,11 +203,11 @@ Check is any column is of NUllType() meaning it's empty column from ForwardRef
**Arguments**:
- `meta (Model class Meta)`: Meta class of the Model without sqlalchemy table constructed
- `meta` (`Model class Meta`): Meta class of the Model without sqlalchemy table constructed
**Returns**:
`(bool)`: result of the check
`bool`: result of the check
<a name="models.helpers.sqlalchemy.populate_meta_sqlalchemy_table_if_required"></a>
#### populate\_meta\_sqlalchemy\_table\_if\_required
@ -221,11 +221,11 @@ It populates name, metadata, columns and constraints.
**Arguments**:
- `meta (Model class Meta)`: Meta class of the Model without sqlalchemy table constructed
- `meta` (`Model class Meta`): Meta class of the Model without sqlalchemy table constructed
**Returns**:
`(Model class)`: class with populated Meta.table
`Model class`: class with populated Meta.table
<a name="models.helpers.sqlalchemy.update_column_definition"></a>
#### update\_column\_definition
@ -238,10 +238,10 @@ Updates a column with a new type column based on updated parameters in FK fields
**Arguments**:
- `model (Type["Model"])`: model on which columns needs to be updated
- `field (ForeignKeyField)`: field with column definition that requires update
- `model` (`Type["Model"]`): model on which columns needs to be updated
- `field` (`ForeignKeyField`): field with column definition that requires update
**Returns**:
`(None)`: None
`None`: None