querymodelling 0.0.5__tar.gz → 0.0.7__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.
- {querymodelling-0.0.5/querymodelling.egg-info → querymodelling-0.0.7}/PKG-INFO +1 -1
- {querymodelling-0.0.5 → querymodelling-0.0.7}/pyproject.toml +1 -1
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling/__version__.py +1 -1
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling/sql.py +8 -15
- {querymodelling-0.0.5 → querymodelling-0.0.7/querymodelling.egg-info}/PKG-INFO +1 -1
- {querymodelling-0.0.5 → querymodelling-0.0.7}/AUTHORS.rst +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/LICENSE +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/README.md +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling/__helper__.py +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling/__init__.py +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling/base.py +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling/fields.py +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling/model.py +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling/pydantic.py +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling.egg-info/SOURCES.txt +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling.egg-info/dependency_links.txt +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling.egg-info/requires.txt +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/querymodelling.egg-info/top_level.txt +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/setup.cfg +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/setup.py +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/tests/__init__.py +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/tests/__main__.py +0 -0
- {querymodelling-0.0.5 → querymodelling-0.0.7}/tests/basic_test.py +0 -0
|
@@ -2,7 +2,6 @@ from datetime import datetime
|
|
|
2
2
|
from sqlmodel import Session, select, func
|
|
3
3
|
from sqlalchemy.orm.attributes import InstrumentedAttribute
|
|
4
4
|
from typing import TypeVar, Sequence, Type, Callable, ParamSpec
|
|
5
|
-
from pydantic import AliasChoices
|
|
6
5
|
|
|
7
6
|
from .__helper__ import is_enum
|
|
8
7
|
from .base import get_functions, DefaultSort
|
|
@@ -70,20 +69,14 @@ def create_query_fields(
|
|
|
70
69
|
json_schema_extra: dict
|
|
71
70
|
):
|
|
72
71
|
for operator, operator_function in operator_mapping.items():
|
|
73
|
-
validation_alias = None
|
|
74
|
-
alias = None
|
|
75
72
|
if operator is None:
|
|
76
73
|
name = field_name
|
|
77
74
|
else:
|
|
78
75
|
name = f"{field_name}_{operator}"
|
|
79
|
-
alias = f"{field_name}.{operator}"
|
|
80
|
-
validation_alias = AliasChoices(name, alias)
|
|
81
76
|
yield (
|
|
82
77
|
name,
|
|
83
78
|
QueryField(base_field)(
|
|
84
79
|
operator_function,
|
|
85
|
-
alias=alias,
|
|
86
|
-
validation_alias=validation_alias,
|
|
87
80
|
default=None,
|
|
88
81
|
json_schema_extra=json_schema_extra | {
|
|
89
82
|
"query.operator": operator
|
|
@@ -95,14 +88,15 @@ def create_query_fields(
|
|
|
95
88
|
def create_callback(
|
|
96
89
|
base_field,
|
|
97
90
|
copy_field_properties: list[str] = None,
|
|
98
|
-
schema_extra: dict = None
|
|
91
|
+
schema_extra: dict = None,
|
|
92
|
+
use_alias_reference: bool = True,
|
|
99
93
|
):
|
|
100
94
|
def auto_create_callback(
|
|
101
95
|
source_type: type,
|
|
102
96
|
field_name: str,
|
|
103
97
|
field,
|
|
104
98
|
field_info,
|
|
105
|
-
annotation
|
|
99
|
+
annotation,
|
|
106
100
|
):
|
|
107
101
|
if copy_field_properties is None and schema_extra is None:
|
|
108
102
|
json_schema_extra = field_info.json_schema_extra
|
|
@@ -114,7 +108,10 @@ def create_callback(
|
|
|
114
108
|
|
|
115
109
|
json_schema_extra = json_schema_extra | {
|
|
116
110
|
"query.backend": "sql",
|
|
117
|
-
"query.field":
|
|
111
|
+
"query.field": (
|
|
112
|
+
(field_info.alias or field_name)
|
|
113
|
+
if use_alias_reference else field_name
|
|
114
|
+
),
|
|
118
115
|
}
|
|
119
116
|
|
|
120
117
|
if annotation == str:
|
|
@@ -158,14 +155,10 @@ def create_callback(
|
|
|
158
155
|
operator_mapping,
|
|
159
156
|
json_schema_extra
|
|
160
157
|
)
|
|
161
|
-
sort_name = f"sort_{field_name}"
|
|
162
|
-
sort_name_dot = f"sort.{field_name}"
|
|
163
158
|
yield (
|
|
164
|
-
|
|
159
|
+
f"sort_{field_name}",
|
|
165
160
|
SortField(base_field)(
|
|
166
161
|
sortable_by(source_type.__dict__[field_name]),
|
|
167
|
-
alias=sort_name_dot,
|
|
168
|
-
validation_alias=AliasChoices(sort_name, sort_name_dot),
|
|
169
162
|
default=None,
|
|
170
163
|
json_schema_extra=json_schema_extra
|
|
171
164
|
),
|
|
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
|