muffin-rest 5.1.4__tar.gz → 5.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/PKG-INFO +1 -1
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/peewee/filters.py +2 -2
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/peewee/sorting.py +1 -1
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/peewee/utils.py +2 -2
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/pyproject.toml +1 -1
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/LICENSE +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/README.rst +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/__init__.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/api.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/errors.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/filters.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/handler.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/mongo/__init__.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/mongo/filters.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/mongo/schema.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/mongo/sorting.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/mongo/types.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/mongo/utils.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/openapi.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/options.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/peewee/__init__.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/peewee/handler.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/peewee/openapi.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/peewee/options.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/peewee/schemas.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/peewee/types.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/py.typed +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/redoc.html +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/sorting.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/sqlalchemy/__init__.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/sqlalchemy/filters.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/sqlalchemy/sorting.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/sqlalchemy/types.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/swagger.html +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/types.py +0 -0
- {muffin_rest-5.1.4 → muffin_rest-5.1.6}/muffin_rest/utils.py +0 -0
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
import operator
|
|
5
5
|
from typing import Any, Callable, Tuple, Type, Union, cast
|
|
6
6
|
|
|
7
|
-
from peewee import Field, ModelSelect
|
|
7
|
+
from peewee import ColumnBase, Field, ModelSelect
|
|
8
8
|
|
|
9
9
|
from muffin_rest.filters import Filter, Filters
|
|
10
10
|
|
|
@@ -37,7 +37,7 @@ class PWFilter(Filter):
|
|
|
37
37
|
|
|
38
38
|
def query(self, qs: ModelSelect, column: Field, *ops: Tuple, **_) -> ModelSelect:
|
|
39
39
|
"""Filter a query."""
|
|
40
|
-
if isinstance(column,
|
|
40
|
+
if isinstance(column, ColumnBase):
|
|
41
41
|
return cast(ModelSelect, qs.where(*[op(column, val) for op, val in ops]))
|
|
42
42
|
|
|
43
43
|
return qs
|
|
@@ -47,7 +47,7 @@ class PWSorting(Sorting):
|
|
|
47
47
|
name = obj
|
|
48
48
|
field = meta.pop("field", None) or name
|
|
49
49
|
if isinstance(field, str):
|
|
50
|
-
field = get_model_field_by_name(handler, field)
|
|
50
|
+
field = get_model_field_by_name(handler, field, stacklevel=6)
|
|
51
51
|
|
|
52
52
|
if field:
|
|
53
53
|
sort = self.MUTATE_CLASS(name, field=field, **meta)
|
|
@@ -8,7 +8,7 @@ if TYPE_CHECKING:
|
|
|
8
8
|
from peewee import Field
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def get_model_field_by_name(handler, name: str) -> Optional[Field]:
|
|
11
|
+
def get_model_field_by_name(handler, name: str, stacklevel=5) -> Optional[Field]:
|
|
12
12
|
"""Get model field by name."""
|
|
13
13
|
fields = handler.meta.model._meta.fields
|
|
14
14
|
candidate = fields.get(name)
|
|
@@ -22,6 +22,6 @@ def get_model_field_by_name(handler, name: str) -> Optional[Field]:
|
|
|
22
22
|
warn(
|
|
23
23
|
f"{handler.__qualname__} {handler.meta.model} has no field {name}",
|
|
24
24
|
category=RuntimeWarning,
|
|
25
|
-
stacklevel=
|
|
25
|
+
stacklevel=stacklevel,
|
|
26
26
|
)
|
|
27
27
|
return None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|