fastapi-sqlalchemy-toolkit 0.6.10__tar.gz → 0.6.12__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.
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/PKG-INFO +1 -1
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/fastapi_sqlalchemy_toolkit/model_manager.py +30 -30
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/pyproject.toml +1 -1
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/.flake8 +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/.github/workflows/python-publish.yml +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/.gitignore +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/.pylintrc +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/AUTHORS +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/LICENSE +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/README.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/.env +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/api/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/api/api.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/api/endpoints/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/api/endpoints/child.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/config.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/db.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/deps.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/main.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/managers.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/models.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/schemas.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/fastapi_sqlalchemy_toolkit/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/fastapi_sqlalchemy_toolkit/filters.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/fastapi_sqlalchemy_toolkit/ordering.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/fastapi_sqlalchemy_toolkit/utils.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/requirements.txt +0 -0
|
@@ -139,7 +139,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
139
139
|
options: List[Any] | Any | None = None,
|
|
140
140
|
order_by: OrderingField | None = None,
|
|
141
141
|
where: Any | None = None,
|
|
142
|
-
|
|
142
|
+
base_stmt: Select | None = None,
|
|
143
143
|
**simple_filters: Any,
|
|
144
144
|
) -> ModelT | Row | None:
|
|
145
145
|
"""
|
|
@@ -153,7 +153,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
153
153
|
|
|
154
154
|
:param where: выражение, которое будет передано в метод .where() SQLAlchemy
|
|
155
155
|
|
|
156
|
-
:param
|
|
156
|
+
:param base_stmt: объект Select для SQL запроса. Если передан, то метод вернёт
|
|
157
157
|
экземпляр Row, а не ModelT.
|
|
158
158
|
Примечание: фильтрация и сортировка по связанным моделям скорее всего
|
|
159
159
|
не будут работать вместе с этим параметром.
|
|
@@ -163,10 +163,10 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
163
163
|
|
|
164
164
|
:returns: экземпляр модели, Row или None, если подходящего нет в БД
|
|
165
165
|
"""
|
|
166
|
-
stmt = self.assemble_stmt(
|
|
166
|
+
stmt = self.assemble_stmt(base_stmt, order_by, options, where, **simple_filters)
|
|
167
167
|
|
|
168
168
|
result = await session.execute(stmt)
|
|
169
|
-
if
|
|
169
|
+
if base_stmt is None:
|
|
170
170
|
return result.scalars().first()
|
|
171
171
|
return result.first()
|
|
172
172
|
|
|
@@ -176,7 +176,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
176
176
|
options: List[Any] | Any | None = None,
|
|
177
177
|
order_by: OrderingField | None = None,
|
|
178
178
|
where: Any | None = None,
|
|
179
|
-
|
|
179
|
+
base_stmt: Select | None = None,
|
|
180
180
|
**simple_filters: Any,
|
|
181
181
|
) -> ModelT | Row:
|
|
182
182
|
"""
|
|
@@ -190,7 +190,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
190
190
|
|
|
191
191
|
:param where: выражение, которое будет передано в метод .where() SQLAlchemy
|
|
192
192
|
|
|
193
|
-
:param
|
|
193
|
+
:param base_stmt: объект Select для SQL запроса. Если передан, то метод вернёт
|
|
194
194
|
экземпляр Row, а не ModelT.
|
|
195
195
|
|
|
196
196
|
:param simple_filters: параметры для фильтрации по точному соответствию,
|
|
@@ -206,14 +206,14 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
206
206
|
options=options,
|
|
207
207
|
order_by=order_by,
|
|
208
208
|
where=where,
|
|
209
|
-
|
|
209
|
+
base_stmt=base_stmt,
|
|
210
210
|
**simple_filters,
|
|
211
211
|
)
|
|
212
212
|
if not db_obj:
|
|
213
213
|
attrs_str = ", ".join(
|
|
214
214
|
[f"{key}={value}" for key, value in simple_filters.items()]
|
|
215
215
|
)
|
|
216
|
-
if where:
|
|
216
|
+
if where is not None:
|
|
217
217
|
attrs_str += f", {where}"
|
|
218
218
|
raise HTTPException(
|
|
219
219
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
@@ -283,7 +283,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
283
283
|
attrs_str = ", ".join(
|
|
284
284
|
[f"{key}={value}" for key, value in simple_filters.items()]
|
|
285
285
|
)
|
|
286
|
-
if where:
|
|
286
|
+
if where is not None:
|
|
287
287
|
attrs_str += f", {where}"
|
|
288
288
|
raise HTTPException(
|
|
289
289
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
@@ -297,7 +297,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
297
297
|
order_by: OrderingField | None = None,
|
|
298
298
|
options: List[Any] | Any | None = None,
|
|
299
299
|
where: Any | None = None,
|
|
300
|
-
|
|
300
|
+
base_stmt: Select | None = None,
|
|
301
301
|
transformer: Callable | None = None,
|
|
302
302
|
**simple_filters: Any,
|
|
303
303
|
) -> BasePage[ModelT | Row]:
|
|
@@ -312,7 +312,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
312
312
|
|
|
313
313
|
:param where: выражение, которое будет передано в метод .where() SQLAlchemy
|
|
314
314
|
|
|
315
|
-
:param
|
|
315
|
+
:param base_stmt: объект Select для SQL запроса. Если передан, то метод вернёт
|
|
316
316
|
страницу Row, а не ModelT.
|
|
317
317
|
|
|
318
318
|
:param transformer: функция для преобразования атрибутов Row к
|
|
@@ -324,7 +324,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
324
324
|
|
|
325
325
|
:returns: пагинированный список объектов или Row
|
|
326
326
|
"""
|
|
327
|
-
stmt = self.assemble_stmt(
|
|
327
|
+
stmt = self.assemble_stmt(base_stmt, order_by, options, where, **simple_filters)
|
|
328
328
|
return await paginate(session, stmt, transformer=transformer)
|
|
329
329
|
|
|
330
330
|
async def paginated_list(
|
|
@@ -336,7 +336,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
336
336
|
| None = None,
|
|
337
337
|
options: List[Any] | Any | None = None,
|
|
338
338
|
where: Any | None = None,
|
|
339
|
-
|
|
339
|
+
base_stmt: Select | None = None,
|
|
340
340
|
transformer: Callable | None = None,
|
|
341
341
|
**simple_filters: Any,
|
|
342
342
|
) -> BasePage[ModelT | Row]:
|
|
@@ -361,7 +361,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
361
361
|
|
|
362
362
|
:param where: выражение, которое будет передано в метод .where() SQLAlchemy
|
|
363
363
|
|
|
364
|
-
:param
|
|
364
|
+
:param base_stmt: объект Select для SQL запроса. Если передан, то метод вернёт
|
|
365
365
|
страницу Row, а не ModelT.
|
|
366
366
|
Примечание: фильтрация и сортировка по связанным моделям скорее всего
|
|
367
367
|
не будет работать вместе с этим параметром.
|
|
@@ -384,7 +384,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
384
384
|
self.handle_nullable_filter_expressions(nullable_filter_expressions)
|
|
385
385
|
filter_expressions = filter_expressions | nullable_filter_expressions
|
|
386
386
|
|
|
387
|
-
stmt = self.assemble_stmt(
|
|
387
|
+
stmt = self.assemble_stmt(base_stmt, order_by, options, where, **simple_filters)
|
|
388
388
|
stmt = self.get_joins(
|
|
389
389
|
stmt,
|
|
390
390
|
options=options,
|
|
@@ -409,7 +409,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
409
409
|
options: List[Any] | Any | None = None,
|
|
410
410
|
where: Any | None = None,
|
|
411
411
|
unique: bool = False,
|
|
412
|
-
|
|
412
|
+
base_stmt: Select | None = None,
|
|
413
413
|
**simple_filters: Any,
|
|
414
414
|
) -> List[ModelT] | List[Row]:
|
|
415
415
|
"""
|
|
@@ -426,7 +426,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
426
426
|
:param unique: определяет необходимость вызова метода .unique()
|
|
427
427
|
у результата SQLAlchemy
|
|
428
428
|
|
|
429
|
-
:param
|
|
429
|
+
:param base_stmt: объект Select для SQL запроса. Если передан, то метод вернёт
|
|
430
430
|
список Row, а не ModelT.
|
|
431
431
|
|
|
432
432
|
:param simple_filters: параметры для фильтрации по точному соответствию,
|
|
@@ -434,10 +434,10 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
434
434
|
|
|
435
435
|
:returns: список объектов или Row
|
|
436
436
|
"""
|
|
437
|
-
stmt = self.assemble_stmt(
|
|
437
|
+
stmt = self.assemble_stmt(base_stmt, order_by, options, where, **simple_filters)
|
|
438
438
|
result = await session.execute(stmt)
|
|
439
439
|
|
|
440
|
-
if
|
|
440
|
+
if base_stmt is None:
|
|
441
441
|
if unique:
|
|
442
442
|
return result.scalars().unique().all()
|
|
443
443
|
return result.scalars().all()
|
|
@@ -453,7 +453,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
453
453
|
options: List[Any] | Any | None = None,
|
|
454
454
|
where: Any | None = None,
|
|
455
455
|
unique: bool = False,
|
|
456
|
-
|
|
456
|
+
base_stmt: Select | None = None,
|
|
457
457
|
**simple_filters: Any,
|
|
458
458
|
) -> List[ModelT] | List[Row]:
|
|
459
459
|
"""
|
|
@@ -480,7 +480,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
480
480
|
:param unique: определяет необходимость вызова метода .unique()
|
|
481
481
|
у результата SQLAlchemy
|
|
482
482
|
|
|
483
|
-
:param
|
|
483
|
+
:param base_stmt: объект Select для SQL запроса. Если передан, то метод вернёт
|
|
484
484
|
список Row, а не ModelT.
|
|
485
485
|
Примечание: фильтрация и сортировка по связанным моделям скорее всего
|
|
486
486
|
не будут работать вместе с этим параметром.
|
|
@@ -499,7 +499,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
499
499
|
self.handle_nullable_filter_expressions(nullable_filter_expressions)
|
|
500
500
|
filter_expressions = filter_expressions | nullable_filter_expressions
|
|
501
501
|
|
|
502
|
-
stmt = self.assemble_stmt(
|
|
502
|
+
stmt = self.assemble_stmt(base_stmt, order_by, options, where, **simple_filters)
|
|
503
503
|
stmt = self.get_joins(
|
|
504
504
|
stmt,
|
|
505
505
|
options=options,
|
|
@@ -515,7 +515,7 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
515
515
|
|
|
516
516
|
result = await session.execute(stmt)
|
|
517
517
|
|
|
518
|
-
if
|
|
518
|
+
if base_stmt is None:
|
|
519
519
|
if unique:
|
|
520
520
|
return result.scalars().unique().all()
|
|
521
521
|
return result.scalars().all()
|
|
@@ -649,9 +649,9 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
649
649
|
await self.validate_unique_constraints(session, in_obj)
|
|
650
650
|
return in_obj
|
|
651
651
|
|
|
652
|
-
def get_select(self,
|
|
653
|
-
if
|
|
654
|
-
return
|
|
652
|
+
def get_select(self, base_stmt: Select | None = None, **kwargs) -> Select:
|
|
653
|
+
if base_stmt is not None:
|
|
654
|
+
return base_stmt
|
|
655
655
|
return select(self.model)
|
|
656
656
|
|
|
657
657
|
def get_joins(
|
|
@@ -759,16 +759,16 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
759
759
|
|
|
760
760
|
def assemble_stmt(
|
|
761
761
|
self,
|
|
762
|
-
|
|
762
|
+
base_stmt: Select | None = None,
|
|
763
763
|
order_by: OrderingField | None = None,
|
|
764
764
|
options: List[Any] | Any | None = None,
|
|
765
765
|
where: Any | None = None,
|
|
766
766
|
**simple_filters: Any,
|
|
767
767
|
) -> Select:
|
|
768
|
-
if
|
|
769
|
-
stmt =
|
|
768
|
+
if base_stmt is not None:
|
|
769
|
+
stmt = base_stmt
|
|
770
770
|
else:
|
|
771
|
-
stmt = self.get_select(
|
|
771
|
+
stmt = self.get_select(base_stmt=base_stmt, order_by=order_by, **simple_filters)
|
|
772
772
|
|
|
773
773
|
for field_name, value in simple_filters.copy().items():
|
|
774
774
|
if field_name in self.reverse_relationships:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/__init__.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/api/__init__.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/api/api.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/config.py
RENAMED
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/deps.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/main.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/managers.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/models.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.10 → fastapi_sqlalchemy_toolkit-0.6.12}/examples/app/schemas.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|