fastapi-sqlalchemy-toolkit 0.7.10__tar.gz → 0.7.11__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.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/PKG-INFO +2 -2
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/sorting.md +5 -5
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/fastapi_sqlalchemy_toolkit/model_manager.py +41 -4
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/pyproject.toml +1 -1
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/.flake8 +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/.github/workflows/docker-test.yml +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/.github/workflows/python-publish.yml +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/.gitignore +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/.pylintrc +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/AUTHORS +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/LICENSE +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/Makefile +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/README.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/benefits.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/db_validation.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/extension.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/filtering.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/index.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/benefits.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/db_validation.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/extension.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/filtering.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/index.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/transactions.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/usage.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/utils.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/sorting.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/transactions.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/usage.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/utils.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/.env +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/api/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/api/api.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/api/deps.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/api/endpoints/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/api/endpoints/child.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/config.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/db.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/main.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/managers.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/models.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/schemas.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/fastapi_sqlalchemy_toolkit/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/fastapi_sqlalchemy_toolkit/filters.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/fastapi_sqlalchemy_toolkit/ordering.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/fastapi_sqlalchemy_toolkit/utils.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/mkdocs.yml +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/requirements/base.txt +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/requirements/docs.txt +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/requirements/lint.txt +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/requirements/test.txt +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/tests/Dockerfile +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/tests/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/tests/conftest.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/tests/db.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/tests/docker-compose.yml +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/tests/models.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/tests/test_public_methods.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi_sqlalchemy_toolkit
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.11
|
|
4
4
|
Summary: FastAPI SQLAlchemy Toolkit
|
|
5
5
|
Project-URL: Homepage, https://github.com/e-kondr01/fastapi-sqlalchemy-toolkit
|
|
6
6
|
Author-email: Egor Kondrashov <e.kondr01@gmail.com>
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
Для применения декларативной сортировки нужно:
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Определить поля, по которым доступна фильтрация
|
|
11
11
|
|
|
12
12
|
Это может быть:
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
- Cписок или кортеж полей основной модели:
|
|
15
15
|
|
|
16
16
|
```python
|
|
17
17
|
from app.models import Child
|
|
@@ -27,7 +27,7 @@ child_ordering_fields = (
|
|
|
27
27
|
|
|
28
28
|
Дефис первым символом означает направление сортировки по убыванию.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
- Маппинг строковых полей для сортировки на соответствующие поля моделей:
|
|
31
31
|
|
|
32
32
|
```python
|
|
33
33
|
from app.models import Child, Parent
|
|
@@ -41,7 +41,7 @@ child_ordering_fields = {
|
|
|
41
41
|
В таком случае, будут доступны следующий параметря для сортировки:
|
|
42
42
|
`title`, `-title`, `parent_title`, `-parent_title`.
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
## В параметрах энпдоинта передать определённый выше список
|
|
45
45
|
в `ordering_depends`
|
|
46
46
|
|
|
47
47
|
```python
|
|
@@ -55,7 +55,7 @@ async def get_child_objects(
|
|
|
55
55
|
...
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
## Передать параметр сортировки как параметр `order_by` в методы `ModelManager`
|
|
59
59
|
|
|
60
60
|
```python
|
|
61
61
|
return await child_manager.list(session=session, order_by=order_by)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ruff: noqa: UP006
|
|
2
2
|
from collections.abc import Callable, Iterable
|
|
3
|
-
from typing import Any, Generic, List, TypeVar # noqa: UP035
|
|
3
|
+
from typing import Any, Generic, List, TypeVar, overload # noqa: UP035
|
|
4
4
|
|
|
5
5
|
from fastapi import HTTPException, status
|
|
6
6
|
from fastapi_pagination.bases import BasePage
|
|
@@ -486,6 +486,8 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
486
486
|
options: List[Any] | Any | None = None,
|
|
487
487
|
where: Any | None = None,
|
|
488
488
|
base_stmt: Select | None = None,
|
|
489
|
+
limit: int | None = None,
|
|
490
|
+
offset: int | None = None,
|
|
489
491
|
*,
|
|
490
492
|
unique: bool = False,
|
|
491
493
|
**simple_filters: Any,
|
|
@@ -507,12 +509,24 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
507
509
|
:param base_stmt: объект Select для SQL запроса. Если передан, то метод вернёт
|
|
508
510
|
список Row, а не ModelT.
|
|
509
511
|
|
|
512
|
+
:param limit: ограничение, передаётся в параметр limit запроса SQLAlchemy
|
|
513
|
+
|
|
514
|
+
:param offset: смещение, передаётся в параметр offset запроса SQLAlchemy
|
|
515
|
+
|
|
510
516
|
:param simple_filters: параметры для фильтрации по точному соответствию,
|
|
511
517
|
аналогично методу .filter_by() SQLAlchemy
|
|
512
518
|
|
|
513
519
|
:returns: список объектов или Row
|
|
514
520
|
"""
|
|
515
|
-
stmt = self.assemble_stmt(
|
|
521
|
+
stmt = self.assemble_stmt(
|
|
522
|
+
base_stmt,
|
|
523
|
+
order_by,
|
|
524
|
+
options,
|
|
525
|
+
where,
|
|
526
|
+
limit=limit,
|
|
527
|
+
offset=offset,
|
|
528
|
+
**simple_filters,
|
|
529
|
+
)
|
|
516
530
|
result = await session.execute(stmt)
|
|
517
531
|
|
|
518
532
|
if base_stmt is None:
|
|
@@ -532,6 +546,8 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
532
546
|
options: List[Any] | Any | None = None,
|
|
533
547
|
where: Any | None = None,
|
|
534
548
|
base_stmt: Select | None = None,
|
|
549
|
+
limit: int | None = None,
|
|
550
|
+
offset: int | None = None,
|
|
535
551
|
*,
|
|
536
552
|
unique: bool = False,
|
|
537
553
|
**simple_filters: Any,
|
|
@@ -565,6 +581,10 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
565
581
|
Примечание: фильтрация и сортировка по связанным моделям скорее всего
|
|
566
582
|
не будут работать вместе с этим параметром.
|
|
567
583
|
|
|
584
|
+
:param limit: ограничение, передаётся в параметр limit запроса SQLAlchemy
|
|
585
|
+
|
|
586
|
+
:param offset: смещение, передаётся в параметр offset запроса SQLAlchemy
|
|
587
|
+
|
|
568
588
|
:param simple_filters: параметры для фильтрации по точному соответствию,
|
|
569
589
|
аналогично методу .filter_by() SQLAlchemy
|
|
570
590
|
|
|
@@ -579,7 +599,15 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
579
599
|
self.handle_nullable_filter_expressions(nullable_filter_expressions)
|
|
580
600
|
filter_expressions = filter_expressions | nullable_filter_expressions
|
|
581
601
|
|
|
582
|
-
stmt = self.assemble_stmt(
|
|
602
|
+
stmt = self.assemble_stmt(
|
|
603
|
+
base_stmt,
|
|
604
|
+
order_by,
|
|
605
|
+
options,
|
|
606
|
+
where,
|
|
607
|
+
limit=limit,
|
|
608
|
+
offset=offset,
|
|
609
|
+
**simple_filters,
|
|
610
|
+
)
|
|
583
611
|
stmt = self.get_joins(
|
|
584
612
|
stmt,
|
|
585
613
|
options=options,
|
|
@@ -669,7 +697,9 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
669
697
|
"""
|
|
670
698
|
update_data = in_obj.model_dump(exclude_unset=exclude_unset) if in_obj else {}
|
|
671
699
|
update_data.update(attrs)
|
|
672
|
-
update_data = await self.run_db_validation(
|
|
700
|
+
update_data = await self.run_db_validation(
|
|
701
|
+
session, db_obj=db_obj, in_obj=update_data
|
|
702
|
+
)
|
|
673
703
|
for field in update_data:
|
|
674
704
|
setattr(db_obj, field, update_data[field])
|
|
675
705
|
await self.save(session, commit=commit)
|
|
@@ -951,6 +981,8 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
951
981
|
order_by: InstrumentedAttribute | UnaryExpression | None = None,
|
|
952
982
|
options: List[Any] | Any | None = None,
|
|
953
983
|
where: Any | None = None,
|
|
984
|
+
limit: int | None = None,
|
|
985
|
+
offset: int | None = None,
|
|
954
986
|
**simple_filters: Any,
|
|
955
987
|
) -> Select:
|
|
956
988
|
if base_stmt is not None:
|
|
@@ -992,6 +1024,11 @@ class ModelManager(Generic[ModelT, CreateSchemaT, UpdateSchemaT]):
|
|
|
992
1024
|
else:
|
|
993
1025
|
stmt = stmt.where(where)
|
|
994
1026
|
|
|
1027
|
+
if limit is not None:
|
|
1028
|
+
stmt = stmt.limit(limit)
|
|
1029
|
+
if offset is not None:
|
|
1030
|
+
stmt = stmt.offset(offset)
|
|
1031
|
+
|
|
995
1032
|
return stmt
|
|
996
1033
|
|
|
997
1034
|
async def validate_fk_exists(
|
|
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
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/db_validation.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/db_validation.md
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/extension.md
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/filtering.md
RENAMED
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/ru/transactions.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/docs/transactions.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/__init__.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/api/__init__.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/api/api.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/api/deps.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/config.py
RENAMED
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/main.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/managers.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/models.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/examples/app/schemas.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/requirements/base.txt
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/requirements/docs.txt
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/requirements/lint.txt
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/requirements/test.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/tests/docker-compose.yml
RENAMED
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.7.10 → fastapi_sqlalchemy_toolkit-0.7.11}/tests/test_public_methods.py
RENAMED
|
File without changes
|