update docs, fix for ellipsis for whole model, some more tests
This commit is contained in:
@ -5,7 +5,7 @@ import sqlalchemy
|
||||
from pydantic import Field, typing
|
||||
from pydantic.fields import FieldInfo
|
||||
|
||||
import ormar # noqa I101
|
||||
import ormar # noqa I101
|
||||
from ormar import ModelDefinitionError # noqa I101
|
||||
|
||||
if TYPE_CHECKING: # pragma no cover
|
||||
|
||||
@ -20,6 +20,8 @@ class Excludable:
|
||||
def is_excluded(exclude: Union[Set, Dict, None], key: str = None) -> bool:
|
||||
if exclude is None:
|
||||
return False
|
||||
if exclude is Ellipsis: # pragma: nocover
|
||||
return True
|
||||
to_exclude = Excludable.get_excluded(exclude=exclude, key=key)
|
||||
if isinstance(to_exclude, Set):
|
||||
return key in to_exclude
|
||||
@ -31,6 +33,8 @@ class Excludable:
|
||||
def is_included(include: Union[Set, Dict, None], key: str = None) -> bool:
|
||||
if include is None:
|
||||
return True
|
||||
if include is Ellipsis:
|
||||
return True
|
||||
to_include = Excludable.get_included(include=include, key=key)
|
||||
if isinstance(to_include, Set):
|
||||
return key in to_include
|
||||
|
||||
@ -67,7 +67,7 @@ class SqlJoin:
|
||||
nested_name: str,
|
||||
) -> Tuple[Optional[Union[Dict, Set]], Optional[Union[Dict, Set]]]:
|
||||
fields = model_cls.get_included(fields, nested_name)
|
||||
exclude_fields = model_cls.get_included(exclude_fields, nested_name)
|
||||
exclude_fields = model_cls.get_excluded(exclude_fields, nested_name)
|
||||
return fields, exclude_fields
|
||||
|
||||
def build_join( # noqa: CCR001
|
||||
|
||||
@ -196,7 +196,7 @@ class QuerySet:
|
||||
if isinstance(columns, str):
|
||||
columns = [columns]
|
||||
|
||||
current_included = self._exclude_columns
|
||||
current_included = self._columns
|
||||
if not isinstance(columns, dict):
|
||||
current_included = update_dict_from_list(current_included, columns)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user