rb-commons 0.6.0__py3-none-any.whl → 0.7.0__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.
- rb_commons/orm/managers.py +9 -1
- {rb_commons-0.6.0.dist-info → rb_commons-0.7.0.dist-info}/METADATA +1 -1
- {rb_commons-0.6.0.dist-info → rb_commons-0.7.0.dist-info}/RECORD +5 -5
- {rb_commons-0.6.0.dist-info → rb_commons-0.7.0.dist-info}/WHEEL +0 -0
- {rb_commons-0.6.0.dist-info → rb_commons-0.7.0.dist-info}/top_level.txt +0 -0
rb_commons/orm/managers.py
CHANGED
@@ -89,6 +89,9 @@ class BaseManager(Generic[ModelType]):
|
|
89
89
|
self._order_by: List[Any] = []
|
90
90
|
self._joins: set[str] = set()
|
91
91
|
|
92
|
+
mapper = inspect(self.model)
|
93
|
+
self._column_keys = [c.key for c in mapper.mapper.column_attrs]
|
94
|
+
|
92
95
|
async def _smart_commit(self, instance: Optional[ModelType] = None) -> Optional[ModelType]:
|
93
96
|
if not self.session.in_transaction():
|
94
97
|
await self.session.commit()
|
@@ -332,9 +335,14 @@ class BaseManager(Generic[ModelType]):
|
|
332
335
|
result = await self.session.execute(stmt)
|
333
336
|
return int(result.scalar_one())
|
334
337
|
|
335
|
-
async def paginate(self, limit: int = 10, offset: int = 0):
|
338
|
+
async def paginate(self, limit: int = 10, offset: int = 0, relations: Optional[Sequence[str]] = None):
|
336
339
|
self._ensure_filtered()
|
337
340
|
stmt = select(self.model).filter(and_(*self.filters))
|
341
|
+
|
342
|
+
if relations:
|
343
|
+
opts = self._build_relation_loaders(self.model, relations)
|
344
|
+
stmt = stmt.options(*opts)
|
345
|
+
|
338
346
|
if self._order_by:
|
339
347
|
stmt = stmt.order_by(*self._order_by)
|
340
348
|
stmt = stmt.limit(limit).offset(offset)
|
@@ -13,7 +13,7 @@ rb_commons/http/consul.py,sha256=Ioq72VD1jGwoC96set7n2SgxN40olzI-myA2lwKkYi4,186
|
|
13
13
|
rb_commons/http/exceptions.py,sha256=EGRMr1cRgiJ9Q2tkfANbf0c6-zzXf1CD6J3cmCaT_FA,1885
|
14
14
|
rb_commons/orm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
15
|
rb_commons/orm/exceptions.py,sha256=1aMctiEwrPjyehoXVX1l6ML5ZOhmDkmBISzlTD5ey1Y,509
|
16
|
-
rb_commons/orm/managers.py,sha256=
|
16
|
+
rb_commons/orm/managers.py,sha256=TIIoZzxlUGscNFj0diWdNNwsajF8ncFFF24mptjxGxU,18312
|
17
17
|
rb_commons/orm/services.py,sha256=71eRcJ4TxZvzNz-hLXo12X4U7PGK54ZfbLAb27AjZi8,1589
|
18
18
|
rb_commons/permissions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
19
|
rb_commons/permissions/role_permissions.py,sha256=4dV89z6ggzLqCCiFYlMp7kQVJRESu6MHpkT5ZNjLo6A,1096
|
@@ -22,7 +22,7 @@ rb_commons/schemes/jwt.py,sha256=ZKLJ5D3fcEmEKySjzbxEgUcza4K-oPoHr14_Z0r9Yic,249
|
|
22
22
|
rb_commons/schemes/pagination.py,sha256=8VZW1wZGJIPR9jEBUgppZUoB4uqP8ORudHkMwvEJSxg,1866
|
23
23
|
rb_commons/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
24
24
|
rb_commons/utils/media.py,sha256=J2Zi0J28DhcVQVzt-myNNVuzj9Msaetul53VjZtdDdc,820
|
25
|
-
rb_commons-0.
|
26
|
-
rb_commons-0.
|
27
|
-
rb_commons-0.
|
28
|
-
rb_commons-0.
|
25
|
+
rb_commons-0.7.0.dist-info/METADATA,sha256=xIB-Y4RnBQGO9Y_UxBecnp_QWChADCuGmqw3SeRuARQ,6570
|
26
|
+
rb_commons-0.7.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
27
|
+
rb_commons-0.7.0.dist-info/top_level.txt,sha256=HPx_WAYo3_fbg1WCeGHsz3wPGio1ucbnrlm2lmqlJog,11
|
28
|
+
rb_commons-0.7.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|