Queryset mixins (#629)
* add enum field * add decorator for asyncio * fix enum typing, additional tests, add docs * add more tests * query-mixin * use dict to replace ordereddict Co-authored-by: collerek <collerek@gmail.com>
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
import collections
|
||||
import itertools
|
||||
import sqlite3
|
||||
from typing import Any, Dict, List, TYPE_CHECKING, Tuple, Type
|
||||
@ -145,7 +144,7 @@ def extract_annotations_and_default_vals(attrs: Dict) -> Tuple[Dict, Dict]:
|
||||
return attrs, model_fields
|
||||
|
||||
|
||||
def group_related_list(list_: List) -> collections.OrderedDict:
|
||||
def group_related_list(list_: List) -> Dict:
|
||||
"""
|
||||
Translates the list of related strings into a dictionary.
|
||||
That way nested models are grouped to traverse them in a right order
|
||||
@ -174,9 +173,7 @@ def group_related_list(list_: List) -> collections.OrderedDict:
|
||||
result_dict[key] = group_related_list(new)
|
||||
else:
|
||||
result_dict.setdefault(key, []).extend(new)
|
||||
return collections.OrderedDict(
|
||||
sorted(result_dict.items(), key=lambda item: len(item[1]))
|
||||
)
|
||||
return dict(sorted(result_dict.items(), key=lambda item: len(item[1])))
|
||||
|
||||
|
||||
def meta_field_not_set(model: Type["Model"], field_name: str) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user