querymodelling 0.0.3__tar.gz → 0.0.5__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.
Files changed (23) hide show
  1. {querymodelling-0.0.3/querymodelling.egg-info → querymodelling-0.0.5}/PKG-INFO +1 -1
  2. {querymodelling-0.0.3 → querymodelling-0.0.5}/pyproject.toml +1 -1
  3. querymodelling-0.0.5/querymodelling/__helper__.py +8 -0
  4. {querymodelling-0.0.3 → querymodelling-0.0.5}/querymodelling/__version__.py +1 -1
  5. {querymodelling-0.0.3 → querymodelling-0.0.5}/querymodelling/sql.py +15 -1
  6. {querymodelling-0.0.3 → querymodelling-0.0.5/querymodelling.egg-info}/PKG-INFO +1 -1
  7. {querymodelling-0.0.3 → querymodelling-0.0.5}/querymodelling.egg-info/SOURCES.txt +1 -0
  8. {querymodelling-0.0.3 → querymodelling-0.0.5}/AUTHORS.rst +0 -0
  9. {querymodelling-0.0.3 → querymodelling-0.0.5}/LICENSE +0 -0
  10. {querymodelling-0.0.3 → querymodelling-0.0.5}/README.md +0 -0
  11. {querymodelling-0.0.3 → querymodelling-0.0.5}/querymodelling/__init__.py +0 -0
  12. {querymodelling-0.0.3 → querymodelling-0.0.5}/querymodelling/base.py +0 -0
  13. {querymodelling-0.0.3 → querymodelling-0.0.5}/querymodelling/fields.py +0 -0
  14. {querymodelling-0.0.3 → querymodelling-0.0.5}/querymodelling/model.py +0 -0
  15. {querymodelling-0.0.3 → querymodelling-0.0.5}/querymodelling/pydantic.py +0 -0
  16. {querymodelling-0.0.3 → querymodelling-0.0.5}/querymodelling.egg-info/dependency_links.txt +0 -0
  17. {querymodelling-0.0.3 → querymodelling-0.0.5}/querymodelling.egg-info/requires.txt +0 -0
  18. {querymodelling-0.0.3 → querymodelling-0.0.5}/querymodelling.egg-info/top_level.txt +0 -0
  19. {querymodelling-0.0.3 → querymodelling-0.0.5}/setup.cfg +0 -0
  20. {querymodelling-0.0.3 → querymodelling-0.0.5}/setup.py +0 -0
  21. {querymodelling-0.0.3 → querymodelling-0.0.5}/tests/__init__.py +0 -0
  22. {querymodelling-0.0.3 → querymodelling-0.0.5}/tests/__main__.py +0 -0
  23. {querymodelling-0.0.3 → querymodelling-0.0.5}/tests/basic_test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: querymodelling
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: build consistent api query models for fastapi
5
5
  Author: George Haddad
6
6
  Author-email: George Haddad <georgeh87@live.de>
@@ -11,7 +11,7 @@ testpaths = ["tests"]
11
11
 
12
12
  [project]
13
13
  name = "querymodelling"
14
- version = "0.0.3"
14
+ version = "0.0.5"
15
15
  description = "build consistent api query models for fastapi"
16
16
  readme = "README.md"
17
17
  requires-python = ">=3.11"
@@ -0,0 +1,8 @@
1
+ from enum import Enum
2
+
3
+
4
+ def is_enum(annotation):
5
+ try:
6
+ return issubclass(annotation, Enum)
7
+ except TypeError:
8
+ return False
@@ -1,7 +1,7 @@
1
1
  __title__ = "querymodelling"
2
2
  __description__ = ""
3
3
  __url__ = "https://querymodelling.readthedocs.io"
4
- __version__ = "0.0.3"
4
+ __version__ = "0.0.5"
5
5
  __build__ = 0x023100
6
6
  __author__ = "George Haddad"
7
7
  __author_email__ = "georgeh87@live.de"
@@ -4,6 +4,7 @@ from sqlalchemy.orm.attributes import InstrumentedAttribute
4
4
  from typing import TypeVar, Sequence, Type, Callable, ParamSpec
5
5
  from pydantic import AliasChoices
6
6
 
7
+ from .__helper__ import is_enum
7
8
  from .base import get_functions, DefaultSort
8
9
  from .fields import QueryField, SortField
9
10
  from .model import PageQuery
@@ -112,7 +113,8 @@ def create_callback(
112
113
  property_name]
113
114
 
114
115
  json_schema_extra = json_schema_extra | {
115
- "query.backend": "sql"
116
+ "query.backend": "sql",
117
+ "query.field": field_name,
116
118
  }
117
119
 
118
120
  if annotation == str:
@@ -144,6 +146,18 @@ def create_callback(
144
146
  operator_mapping,
145
147
  json_schema_extra
146
148
  )
149
+ elif is_enum(annotation):
150
+ operator_mapping = {
151
+ None: lambda value: field == value,
152
+ "not": lambda value: field != value
153
+ }
154
+ yield from create_query_fields(
155
+ base_field,
156
+ field_name,
157
+ annotation,
158
+ operator_mapping,
159
+ json_schema_extra
160
+ )
147
161
  sort_name = f"sort_{field_name}"
148
162
  sort_name_dot = f"sort.{field_name}"
149
163
  yield (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: querymodelling
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: build consistent api query models for fastapi
5
5
  Author: George Haddad
6
6
  Author-email: George Haddad <georgeh87@live.de>
@@ -3,6 +3,7 @@ LICENSE
3
3
  README.md
4
4
  pyproject.toml
5
5
  setup.py
6
+ querymodelling/__helper__.py
6
7
  querymodelling/__init__.py
7
8
  querymodelling/__version__.py
8
9
  querymodelling/base.py
File without changes
File without changes
File without changes
File without changes