fastapi-sqlalchemy-toolkit 0.8.2__py3-none-any.whl → 0.8.2.2__py3-none-any.whl
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.
- fastapi_sqlalchemy_toolkit/model_manager.py +29 -10
- {fastapi_sqlalchemy_toolkit-0.8.2.dist-info → fastapi_sqlalchemy_toolkit-0.8.2.2.dist-info}/METADATA +1 -1
- fastapi_sqlalchemy_toolkit-0.8.2.2.dist-info/RECORD +10 -0
- fastapi_sqlalchemy_toolkit-0.8.2.dist-info/RECORD +0 -10
- {fastapi_sqlalchemy_toolkit-0.8.2.dist-info → fastapi_sqlalchemy_toolkit-0.8.2.2.dist-info}/WHEEL +0 -0
- {fastapi_sqlalchemy_toolkit-0.8.2.dist-info → fastapi_sqlalchemy_toolkit-0.8.2.2.dist-info}/licenses/AUTHORS +0 -0
- {fastapi_sqlalchemy_toolkit-0.8.2.dist-info → fastapi_sqlalchemy_toolkit-0.8.2.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1148,10 +1148,8 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
1148
1148
|
model = filter_expression.parent._identity_class
|
|
1149
1149
|
elif isinstance(filter_expression, Function):
|
|
1150
1150
|
model = filter_expression.entity_namespace
|
|
1151
|
-
elif isinstance(filter_expression, ColumnElement):
|
|
1152
|
-
model = self.model # Not supported
|
|
1153
1151
|
else:
|
|
1154
|
-
model =
|
|
1152
|
+
model = self.model # Not supported
|
|
1155
1153
|
if model != self.model:
|
|
1156
1154
|
models_to_join.add(model)
|
|
1157
1155
|
for model in models_to_join:
|
|
@@ -1235,10 +1233,10 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
1235
1233
|
related_pk = _get_model_pk(related_model)
|
|
1236
1234
|
return relationship.any(related_pk.in_(value))
|
|
1237
1235
|
|
|
1238
|
-
@
|
|
1239
|
-
def
|
|
1236
|
+
@classmethod
|
|
1237
|
+
def handle_optional_where_expression(cls, optional_where: Any) -> Any:
|
|
1240
1238
|
"""
|
|
1241
|
-
Обрабатывает выражение optional_where, пропуская
|
|
1239
|
+
Обрабатывает одно выражение optional_where, пропуская фильтр, если его значение None.
|
|
1242
1240
|
|
|
1243
1241
|
Поддерживает:
|
|
1244
1242
|
1. Простые выражения вида MyModel.field == value
|
|
@@ -1273,6 +1271,30 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
1273
1271
|
return None
|
|
1274
1272
|
return optional_where
|
|
1275
1273
|
|
|
1274
|
+
@classmethod
|
|
1275
|
+
def handle_optional_where(cls, optional_where: Any) -> Any:
|
|
1276
|
+
"""
|
|
1277
|
+
Обрабатывает выражения optional_where, пропуская фильтры, значения которых None.
|
|
1278
|
+
|
|
1279
|
+
Принимает одно выражение SQLAlchemy или кортеж выражений.
|
|
1280
|
+
Каждое выражение обрабатывается через handle_optional_where_expression
|
|
1281
|
+
и поддерживает все три вида выражений.
|
|
1282
|
+
При передаче кортежа оставшиеся (не-None) выражения
|
|
1283
|
+
объединяются через оператор &.
|
|
1284
|
+
"""
|
|
1285
|
+
if isinstance(optional_where, tuple):
|
|
1286
|
+
remaining = []
|
|
1287
|
+
for arg in optional_where:
|
|
1288
|
+
processed = cls.handle_optional_where_expression(arg)
|
|
1289
|
+
if processed is not None:
|
|
1290
|
+
remaining.append(processed)
|
|
1291
|
+
if not remaining:
|
|
1292
|
+
return None
|
|
1293
|
+
if len(remaining) == 1:
|
|
1294
|
+
return remaining[0]
|
|
1295
|
+
return and_(*remaining)
|
|
1296
|
+
return cls.handle_optional_where_expression(optional_where)
|
|
1297
|
+
|
|
1276
1298
|
def assemble_stmt(
|
|
1277
1299
|
self,
|
|
1278
1300
|
base_stmt: Select | None = None,
|
|
@@ -1317,10 +1339,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
1317
1339
|
stmt = stmt.options(option)
|
|
1318
1340
|
|
|
1319
1341
|
if where is not None:
|
|
1320
|
-
if isinstance(where, tuple)
|
|
1321
|
-
stmt = stmt.where(*where)
|
|
1322
|
-
else:
|
|
1323
|
-
stmt = stmt.where(where)
|
|
1342
|
+
stmt = stmt.where(*where) if isinstance(where, tuple) else stmt.where(where)
|
|
1324
1343
|
|
|
1325
1344
|
if limit is not None:
|
|
1326
1345
|
stmt = stmt.limit(limit)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
fastapi_sqlalchemy_toolkit/__init__.py,sha256=CQ25ahHAdk8r8NlXCq9YWm9wYA_rJfq1UlFG8Ra0sOU,225
|
|
2
|
+
fastapi_sqlalchemy_toolkit/filters.py,sha256=RxvyNTGhkTbEVvIOyXZf2t3n8B5TQidSkM4cJOzGEsw,97
|
|
3
|
+
fastapi_sqlalchemy_toolkit/model_manager.py,sha256=uy1IrJtVU-8l_j71l2qNArXvihg4Si5ieJTU1Eyo8Qc,62730
|
|
4
|
+
fastapi_sqlalchemy_toolkit/ordering.py,sha256=9f4IBunXtUybYedQnJZbNsCAcUgdSztIhAHqHa1iG60,2953
|
|
5
|
+
fastapi_sqlalchemy_toolkit/utils.py,sha256=EVDYAgI2wQmskxjeS_Ho3qmNAWf4PEExMVyslF32TIk,1966
|
|
6
|
+
fastapi_sqlalchemy_toolkit-0.8.2.2.dist-info/METADATA,sha256=nigkOg_bKF6rKgy35lHsQboZYafc-g90NuK7Uw6iNJQ,2347
|
|
7
|
+
fastapi_sqlalchemy_toolkit-0.8.2.2.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
8
|
+
fastapi_sqlalchemy_toolkit-0.8.2.2.dist-info/licenses/AUTHORS,sha256=fnn-xBK_5emc8NbrMRYGH1WbiVyiBkhnxxD3cNi0TY8,384
|
|
9
|
+
fastapi_sqlalchemy_toolkit-0.8.2.2.dist-info/licenses/LICENSE,sha256=hOWlRBgw7tkevaCGpz9j-ry_rF2v1D-6LCEC63Sfq1c,1081
|
|
10
|
+
fastapi_sqlalchemy_toolkit-0.8.2.2.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
fastapi_sqlalchemy_toolkit/__init__.py,sha256=CQ25ahHAdk8r8NlXCq9YWm9wYA_rJfq1UlFG8Ra0sOU,225
|
|
2
|
-
fastapi_sqlalchemy_toolkit/filters.py,sha256=RxvyNTGhkTbEVvIOyXZf2t3n8B5TQidSkM4cJOzGEsw,97
|
|
3
|
-
fastapi_sqlalchemy_toolkit/model_manager.py,sha256=doXUS-_zpDOTVtkL2cUFhrGFF-xpGNSV2syxLrMzMzY,61682
|
|
4
|
-
fastapi_sqlalchemy_toolkit/ordering.py,sha256=9f4IBunXtUybYedQnJZbNsCAcUgdSztIhAHqHa1iG60,2953
|
|
5
|
-
fastapi_sqlalchemy_toolkit/utils.py,sha256=EVDYAgI2wQmskxjeS_Ho3qmNAWf4PEExMVyslF32TIk,1966
|
|
6
|
-
fastapi_sqlalchemy_toolkit-0.8.2.dist-info/METADATA,sha256=OyTVsqdFixa3L97cWVRK-E7MDy5mJRDAzqCgSNvPfA8,2345
|
|
7
|
-
fastapi_sqlalchemy_toolkit-0.8.2.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
8
|
-
fastapi_sqlalchemy_toolkit-0.8.2.dist-info/licenses/AUTHORS,sha256=fnn-xBK_5emc8NbrMRYGH1WbiVyiBkhnxxD3cNi0TY8,384
|
|
9
|
-
fastapi_sqlalchemy_toolkit-0.8.2.dist-info/licenses/LICENSE,sha256=hOWlRBgw7tkevaCGpz9j-ry_rF2v1D-6LCEC63Sfq1c,1081
|
|
10
|
-
fastapi_sqlalchemy_toolkit-0.8.2.dist-info/RECORD,,
|
{fastapi_sqlalchemy_toolkit-0.8.2.dist-info → fastapi_sqlalchemy_toolkit-0.8.2.2.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|