refactor order bys into OrderQuery, add ordering to through models too

This commit is contained in:
collerek
2021-02-25 17:28:05 +01:00
parent c139ca4f61
commit 503f589fa7
16 changed files with 388 additions and 210 deletions

View File

@ -2,7 +2,7 @@ from typing import Callable, Dict, List, TYPE_CHECKING, Tuple, Type, cast
from ormar.models.mixins.relation_mixin import RelationMixin
if TYPE_CHECKING:
if TYPE_CHECKING: # pragma: no cover
from ormar.fields import ForeignKeyField, ManyToManyField
@ -18,10 +18,10 @@ class PrefetchQueryMixin(RelationMixin):
@staticmethod
def get_clause_target_and_filter_column_name(
parent_model: Type["Model"],
target_model: Type["Model"],
reverse: bool,
related: str,
parent_model: Type["Model"],
target_model: Type["Model"],
reverse: bool,
related: str,
) -> Tuple[Type["Model"], str]:
"""
Returns Model on which query clause should be performed and name of the column.
@ -51,7 +51,7 @@ class PrefetchQueryMixin(RelationMixin):
@staticmethod
def get_column_name_for_id_extraction(
parent_model: Type["Model"], reverse: bool, related: str, use_raw: bool,
parent_model: Type["Model"], reverse: bool, related: str, use_raw: bool,
) -> str:
"""
Returns name of the column that should be used to extract ids from model.

View File

@ -17,7 +17,7 @@ from ormar.models import NewBaseModel # noqa: I202
from ormar.models.helpers.models import group_related_list
if TYPE_CHECKING:
if TYPE_CHECKING: # pragma: no cover
from ormar.fields import ForeignKeyField
from ormar.models import T
else: