fastapi-sqlalchemy-toolkit 0.6.4__tar.gz → 0.6.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.
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/PKG-INFO +1 -1
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/fastapi_sqlalchemy_toolkit/model_manager.py +50 -9
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/pyproject.toml +1 -1
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/.flake8 +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/.github/workflows/python-publish.yml +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/.gitignore +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/.pylintrc +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/AUTHORS +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/LICENSE +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/README.md +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/.env +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/api/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/api/api.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/api/endpoints/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/api/endpoints/child.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/config.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/db.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/deps.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/main.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/managers.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/models.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/schemas.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/fastapi_sqlalchemy_toolkit/__init__.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/fastapi_sqlalchemy_toolkit/filters.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/fastapi_sqlalchemy_toolkit/ordering.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/fastapi_sqlalchemy_toolkit/utils.py +0 -0
- {fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/requirements.txt +0 -0
|
@@ -180,7 +180,7 @@ class ModelManager(Generic[ModelType, CreateSchemaType, UpdateSchemaType]):
|
|
|
180
180
|
**simple_filters: Any,
|
|
181
181
|
) -> ModelType | Row:
|
|
182
182
|
"""
|
|
183
|
-
Получение одного экземпляра модели или
|
|
183
|
+
Получение одного экземпляра модели или вызов HTTP исключения 404.
|
|
184
184
|
|
|
185
185
|
:param session: сессия SQLAlchemy
|
|
186
186
|
|
|
@@ -209,10 +209,12 @@ class ModelManager(Generic[ModelType, CreateSchemaType, UpdateSchemaType]):
|
|
|
209
209
|
select_=select_,
|
|
210
210
|
**simple_filters,
|
|
211
211
|
)
|
|
212
|
-
attrs_str = ", ".join(
|
|
213
|
-
[f"{key}={value}" for key, value in simple_filters.items()]
|
|
214
|
-
)
|
|
215
212
|
if not db_obj:
|
|
213
|
+
attrs_str = ", ".join(
|
|
214
|
+
[f"{key}={value}" for key, value in simple_filters.items()]
|
|
215
|
+
)
|
|
216
|
+
if where:
|
|
217
|
+
attrs_str += f", {where}"
|
|
216
218
|
raise HTTPException(
|
|
217
219
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
218
220
|
detail=f"{self.model.__tablename__} with {attrs_str} not found",
|
|
@@ -223,7 +225,6 @@ class ModelManager(Generic[ModelType, CreateSchemaType, UpdateSchemaType]):
|
|
|
223
225
|
self,
|
|
224
226
|
session: AsyncSession,
|
|
225
227
|
options: List[Any] | Any | None = None,
|
|
226
|
-
order_by: OrderingField | None = None,
|
|
227
228
|
where: Any | None = None,
|
|
228
229
|
**simple_filters: Any,
|
|
229
230
|
) -> bool:
|
|
@@ -234,8 +235,6 @@ class ModelManager(Generic[ModelType, CreateSchemaType, UpdateSchemaType]):
|
|
|
234
235
|
|
|
235
236
|
:param options: параметры для метода .options() загрузчика SQLAlchemy
|
|
236
237
|
|
|
237
|
-
:param order_by: поле для сортировки (экземпляр OrderingField)
|
|
238
|
-
|
|
239
238
|
:param where: выражение, которое будет передано в метод .where() SQLAlchemy
|
|
240
239
|
|
|
241
240
|
:param simple_filters: параметры для фильтрации по точному соответствию,
|
|
@@ -244,12 +243,54 @@ class ModelManager(Generic[ModelType, CreateSchemaType, UpdateSchemaType]):
|
|
|
244
243
|
:returns: True если объект существует, иначе False
|
|
245
244
|
"""
|
|
246
245
|
stmt = self.assemble_stmt(
|
|
247
|
-
select(self.model.id),
|
|
246
|
+
select(self.model.id), None, options, where, **simple_filters
|
|
248
247
|
)
|
|
249
|
-
|
|
250
248
|
result = await session.execute(stmt)
|
|
251
249
|
return result.first() is not None
|
|
252
250
|
|
|
251
|
+
async def exists_or_404(
|
|
252
|
+
self,
|
|
253
|
+
session: AsyncSession,
|
|
254
|
+
options: List[Any] | Any | None = None,
|
|
255
|
+
where: Any | None = None,
|
|
256
|
+
**simple_filters: Any,
|
|
257
|
+
) -> bool:
|
|
258
|
+
"""
|
|
259
|
+
Проверка существования экземпляра модели.
|
|
260
|
+
Если объект не существует, вызывает HTTP исключение 404.
|
|
261
|
+
|
|
262
|
+
:param session: сессия SQLAlchemy
|
|
263
|
+
|
|
264
|
+
:param options: параметры для метода .options() загрузчика SQLAlchemy
|
|
265
|
+
|
|
266
|
+
:param where: выражение, которое будет передано в метод .where() SQLAlchemy
|
|
267
|
+
|
|
268
|
+
:param simple_filters: параметры для фильтрации по точному соответствию,
|
|
269
|
+
аналогично методу .filter_by() SQLAlchemy
|
|
270
|
+
|
|
271
|
+
:returns: True, если объект существует
|
|
272
|
+
|
|
273
|
+
:raises: fastapi.HTTPException 404
|
|
274
|
+
"""
|
|
275
|
+
|
|
276
|
+
exists = await self.exists(
|
|
277
|
+
session,
|
|
278
|
+
options=options,
|
|
279
|
+
where=where,
|
|
280
|
+
**simple_filters,
|
|
281
|
+
)
|
|
282
|
+
if not exists:
|
|
283
|
+
attrs_str = ", ".join(
|
|
284
|
+
[f"{key}={value}" for key, value in simple_filters.items()]
|
|
285
|
+
)
|
|
286
|
+
if where:
|
|
287
|
+
attrs_str += f", {where}"
|
|
288
|
+
raise HTTPException(
|
|
289
|
+
status_code=status.HTTP_404_NOT_FOUND,
|
|
290
|
+
detail=f"{self.model.__tablename__} with {attrs_str} does not exist",
|
|
291
|
+
)
|
|
292
|
+
return True
|
|
293
|
+
|
|
253
294
|
async def paginated_filter(
|
|
254
295
|
self,
|
|
255
296
|
session: AsyncSession,
|
|
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.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/__init__.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/api/__init__.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/api/api.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/managers.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/models.py
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_toolkit-0.6.4 → fastapi_sqlalchemy_toolkit-0.6.5}/examples/app/schemas.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|