fix isnull typo and formatting
This commit is contained in:
@ -19,7 +19,7 @@ in the end all parent (main) models should be unique.
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| merge_instances_list(cls, result_rows: Sequence["Model"]) -> Sequence["Model"]
|
||||
| merge_instances_list(cls, result_rows: List["Model"]) -> List["Model"]
|
||||
```
|
||||
|
||||
Merges a list of models into list of unique models.
|
||||
@ -41,7 +41,7 @@ populated, each instance is one row in db and some models can duplicate
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| merge_two_instances(cls, one: "Model", other: "Model") -> "Model"
|
||||
| merge_two_instances(cls, one: "Model", other: "Model", relation_map: Dict = None) -> "Model"
|
||||
```
|
||||
|
||||
Merges current (other) Model and previous one (one) and returns the current
|
||||
@ -51,6 +51,7 @@ If needed it's calling itself recurrently and merges also children models.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `relation_map (Dict)`: map of models relations to follow
|
||||
- `one (Model)`: previous model instance
|
||||
- `other (Model)`: current model instance
|
||||
|
||||
@ -58,3 +59,30 @@ If needed it's calling itself recurrently and merges also children models.
|
||||
|
||||
`(Model)`: current Model instance with data merged from previous one.
|
||||
|
||||
<a name="models.mixins.merge_mixin.MergeModelMixin._merge_items_lists"></a>
|
||||
#### \_merge\_items\_lists
|
||||
|
||||
```python
|
||||
| @classmethod
|
||||
| _merge_items_lists(cls, field_name: str, current_field: List, other_value: List, relation_map: Optional[Dict]) -> List
|
||||
```
|
||||
|
||||
Takes two list of nested models and process them going deeper
|
||||
according with the map.
|
||||
|
||||
If model from one's list is in other -> they are merged with relations
|
||||
to follow passed from map.
|
||||
|
||||
If one's model is not in other it's simply appended to the list.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `field_name (str)`: name of the current relation field
|
||||
- `current_field (List[Model])`: list of nested models from one model
|
||||
- `other_value (List[Model])`: list of nested models from other model
|
||||
- `relation_map (Dict)`: map of relations to follow
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(List[Model])`: merged list of models
|
||||
|
||||
|
||||
Reference in New Issue
Block a user