fastapi-extra 0.1.7__cp312-cp312-win_amd64.whl → 0.1.8__cp312-cp312-win_amd64.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_extra/__init__.py +1 -1
- fastapi_extra/cursor.cp312-win_amd64.pyd +0 -0
- fastapi_extra/database/model.py +1 -1
- fastapi_extra/database/service.py +9 -7
- fastapi_extra/database/session.py +2 -0
- fastapi_extra/py.typed +0 -0
- fastapi_extra/routing.cp312-win_amd64.pyd +0 -0
- {fastapi_extra-0.1.7.dist-info → fastapi_extra-0.1.8.dist-info}/METADATA +1 -1
- {fastapi_extra-0.1.7.dist-info → fastapi_extra-0.1.8.dist-info}/RECORD +12 -11
- {fastapi_extra-0.1.7.dist-info → fastapi_extra-0.1.8.dist-info}/WHEEL +1 -1
- {fastapi_extra-0.1.7.dist-info → fastapi_extra-0.1.8.dist-info}/LICENSE +0 -0
- {fastapi_extra-0.1.7.dist-info → fastapi_extra-0.1.8.dist-info}/top_level.txt +0 -0
fastapi_extra/__init__.py
CHANGED
|
Binary file
|
fastapi_extra/database/model.py
CHANGED
|
@@ -12,7 +12,7 @@ Model = TypeVar("Model", bound=SQLModel)
|
|
|
12
12
|
|
|
13
13
|
class ModelService(AbstractDependency, Generic[Model], annotated=False):
|
|
14
14
|
__slot__ = ("session", )
|
|
15
|
-
__model__:
|
|
15
|
+
__model__: Model
|
|
16
16
|
|
|
17
17
|
@classmethod
|
|
18
18
|
def __class_getitem__(cls, item: type[SQLModel]) -> Self:
|
|
@@ -20,8 +20,11 @@ class ModelService(AbstractDependency, Generic[Model], annotated=False):
|
|
|
20
20
|
raise TypeError(f"type[SQLModel] expected, got {item}")
|
|
21
21
|
if not (table_arg := item.model_config.get("table", None)):
|
|
22
22
|
raise AttributeError(f"True expected for argument {item.__name__}.model_config.table, got {table_arg}")
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
|
|
24
|
+
class SubService(ModelService):
|
|
25
|
+
__model__ = item
|
|
26
|
+
|
|
27
|
+
return SubService
|
|
25
28
|
|
|
26
29
|
def __init__(self, session: DefaultSession):
|
|
27
30
|
self.session = session
|
|
@@ -29,12 +32,11 @@ class ModelService(AbstractDependency, Generic[Model], annotated=False):
|
|
|
29
32
|
async def get(self, ident: int | str, **kwargs: Any) -> Model | None:
|
|
30
33
|
return await self.session.get(self.__model__, ident, **kwargs)
|
|
31
34
|
|
|
32
|
-
async def create(self, model: Model) -> Model:
|
|
33
|
-
return await self.session.add(model)
|
|
34
|
-
|
|
35
35
|
async def create_model(self, **kwargs: Any) -> Model:
|
|
36
36
|
model = self.__model__.model_validate(kwargs)
|
|
37
|
-
|
|
37
|
+
self.session.add(model)
|
|
38
|
+
await self.session.flush()
|
|
39
|
+
return model
|
|
38
40
|
|
|
39
41
|
async def delete(self, model: Model) -> Model:
|
|
40
42
|
return await self.session.delete(model)
|
|
@@ -14,11 +14,13 @@ from fastapi_extra.database.driver import DB, AsyncDB
|
|
|
14
14
|
async def get_async_session(db: AsyncDB) -> AsyncGenerator[AsyncSession, None]:
|
|
15
15
|
async with db.session as session:
|
|
16
16
|
yield session
|
|
17
|
+
await session.commit()
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
def get_session(db: DB) -> Generator[Session, None, None]:
|
|
20
21
|
with db.session as session:
|
|
21
22
|
yield session
|
|
23
|
+
session.commit()
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
DefaultSession = Annotated[AsyncSession, Depends(get_async_session)]
|
fastapi_extra/py.typed
ADDED
|
File without changes
|
|
Binary file
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
fastapi_extra/__init__.py,sha256=
|
|
2
|
-
fastapi_extra/cursor.cp312-win_amd64.pyd,sha256=
|
|
1
|
+
fastapi_extra/__init__.py,sha256=VmSUMSzhrVb6zSyHIl2-mi71gyGRMC9n400N5Gr3aT8,286
|
|
2
|
+
fastapi_extra/cursor.cp312-win_amd64.pyd,sha256=cuMCDVcrH1ltvx1s2zm2PXsbkj20hP-plud-YBKI9D8,57344
|
|
3
3
|
fastapi_extra/dependency.py,sha256=8SgAky63hMa9pnttqRRZMyPAa3BwBMUvFA3ZLH86h44,910
|
|
4
4
|
fastapi_extra/form.py,sha256=Fs9uEDOQThjFroDVTrjWnIGJ107BgXCppIVTymwQLzg,1247
|
|
5
|
+
fastapi_extra/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
6
|
fastapi_extra/response.py,sha256=DHvhOSgwot5eBNKuI_jPYxZ5rshZ55Xkg-FNBJlHD1E,9609
|
|
6
|
-
fastapi_extra/routing.cp312-win_amd64.pyd,sha256=
|
|
7
|
+
fastapi_extra/routing.cp312-win_amd64.pyd,sha256=6ZHARNFCgL_tlmp6WPSZMR07yrlPe2WAg5jpeXFQTfc,94720
|
|
7
8
|
fastapi_extra/settings.py,sha256=cCcwaper5GiNNoT4gNKqf-iloSOTNnMsiUR0knJx4Mw,1461
|
|
8
9
|
fastapi_extra/types.py,sha256=3z6gUnao6WZL76asZYmex20xfY9mvYA-RbnsxUcui30,819
|
|
9
10
|
fastapi_extra/utils.py,sha256=tsPX3kpF_P5D9Bd3gnlG6rkVsLkv5gbxjml-s6ZL_6I,346
|
|
@@ -11,13 +12,13 @@ fastapi_extra/cache/__init__.py,sha256=2bwWFRf6giDo0QiFWEvekQwga9kGTK_9BJdxe32Nr
|
|
|
11
12
|
fastapi_extra/cache/redis.py,sha256=fLNJfL8V-HYek38WVNwxvW6cnd7rJpcd62vy4O07C44,1592
|
|
12
13
|
fastapi_extra/database/__init__.py,sha256=B59umaoNjDuXyoNh7EYWYEk4xr9tfgVjXsSaOPz3y_Q,328
|
|
13
14
|
fastapi_extra/database/driver.py,sha256=ar_vnfqjpoWjiW5eEdrisyi9CrhfdHtbhAGFxGMKC5E,2223
|
|
14
|
-
fastapi_extra/database/model.py,sha256=
|
|
15
|
-
fastapi_extra/database/service.py,sha256=
|
|
16
|
-
fastapi_extra/database/session.py,sha256=
|
|
15
|
+
fastapi_extra/database/model.py,sha256=2ISHT0NUz3-uoqlogxrthzM6GxAfPdghzx1j-lvkSRQ,2451
|
|
16
|
+
fastapi_extra/database/service.py,sha256=TdKlcTQ_WoMqy-kmlYUcFKF7XpyFL8O4vkQ2glZc7P4,1495
|
|
17
|
+
fastapi_extra/database/session.py,sha256=cpKj_NDBSATRCBbmfyYa4v-TKGrMMgRJQCEnkCR153s,691
|
|
17
18
|
fastapi_extra/native/cursor.pyx,sha256=bESprFDgk9gGjyPQ4YCSg51dov2WB6s60XrOs3r5-r0,1146
|
|
18
19
|
fastapi_extra/native/routing.pyx,sha256=GrdGAoBospwCpxMHBon5cuRYcz9ifAFSSYa2Ytf49lg,3841
|
|
19
|
-
fastapi_extra-0.1.
|
|
20
|
-
fastapi_extra-0.1.
|
|
21
|
-
fastapi_extra-0.1.
|
|
22
|
-
fastapi_extra-0.1.
|
|
23
|
-
fastapi_extra-0.1.
|
|
20
|
+
fastapi_extra-0.1.8.dist-info/LICENSE,sha256=0vTjHDa3VDsxTT-R-sH6SpYcA2F1hKtbX9ZFZQm-EcU,1516
|
|
21
|
+
fastapi_extra-0.1.8.dist-info/METADATA,sha256=Mg9fJV2_mAo_PZXq3JCq_Mv9t69noysoU7HmNnN1wzA,1348
|
|
22
|
+
fastapi_extra-0.1.8.dist-info/WHEEL,sha256=A8mRFNvJcDL8dRPZ6k2ICKEOXwE8pzYFXYxEla0rR0g,101
|
|
23
|
+
fastapi_extra-0.1.8.dist-info/top_level.txt,sha256=B7D80bEftE2E-eSd1be2r9BWkLLMZN21dRTWpb4y4Ig,14
|
|
24
|
+
fastapi_extra-0.1.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|