rb-commons 0.4.11__tar.gz → 0.4.13__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.
- {rb_commons-0.4.11 → rb_commons-0.4.13}/PKG-INFO +1 -1
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/orm/managers.py +27 -8
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons.egg-info/PKG-INFO +1 -1
- {rb_commons-0.4.11 → rb_commons-0.4.13}/setup.py +1 -1
- {rb_commons-0.4.11 → rb_commons-0.4.13}/README.md +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/__init__.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/broker/__init__.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/broker/consumer.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/configs/__init__.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/configs/config.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/configs/injections.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/configs/rabbitmq.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/http/__init__.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/http/base_api.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/http/consul.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/http/exceptions.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/orm/__init__.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/orm/exceptions.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/orm/services.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/permissions/__init__.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/permissions/role_permissions.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/schemes/__init__.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/schemes/jwt.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/schemes/pagination.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/utils/__init__.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons/utils/media.py +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons.egg-info/SOURCES.txt +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons.egg-info/dependency_links.txt +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons.egg-info/requires.txt +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/rb_commons.egg-info/top_level.txt +0 -0
- {rb_commons-0.4.11 → rb_commons-0.4.13}/setup.cfg +0 -0
@@ -103,6 +103,7 @@ class BaseManager(Generic[ModelType]):
|
|
103
103
|
- __lte (field__lte=value)
|
104
104
|
- __in (field__in=[val1, val2, ...])
|
105
105
|
- __contains (field__contains='text')
|
106
|
+
- __null (field__null=True/False) - True for IS NULL, False for IS NOT NULL
|
106
107
|
|
107
108
|
Additionally supports nested paths, e.g.,
|
108
109
|
product__shop_id=None
|
@@ -116,7 +117,7 @@ class BaseManager(Generic[ModelType]):
|
|
116
117
|
|
117
118
|
operator = "eq"
|
118
119
|
|
119
|
-
if parts[-1] in {"eq", "ne", "gt", "lt", "gte", "lte", "in", "contains"}:
|
120
|
+
if parts[-1] in {"eq", "ne", "gt", "lt", "gte", "lte", "in", "contains", "null"}:
|
120
121
|
operator = parts.pop()
|
121
122
|
|
122
123
|
current_attr = self.model
|
@@ -159,6 +160,12 @@ class BaseManager(Generic[ModelType]):
|
|
159
160
|
elif operator == "contains":
|
160
161
|
# e.g., column ILIKE %value%
|
161
162
|
self.filters.append(current_attr.ilike(f"%{value}%"))
|
163
|
+
|
164
|
+
elif operator == "null":
|
165
|
+
if value is True:
|
166
|
+
self.filters.append(current_attr.is_(None))
|
167
|
+
else:
|
168
|
+
self.filters.append(current_attr.isnot(None))
|
162
169
|
|
163
170
|
return self
|
164
171
|
|
@@ -174,15 +181,27 @@ class BaseManager(Generic[ModelType]):
|
|
174
181
|
unique_by_pk = {obj.id: obj for obj in rows}
|
175
182
|
return list(unique_by_pk.values())
|
176
183
|
|
177
|
-
async def all(self, load_all_relations: bool = False) -> List[ModelType]:
|
178
|
-
|
179
|
-
|
184
|
+
async def all(self, load_all_relations: bool = False) -> List[ModelType] | None:
|
185
|
+
try:
|
186
|
+
stmt = select(self.model)
|
180
187
|
|
181
|
-
|
182
|
-
|
183
|
-
self._limit = None
|
188
|
+
if self._filtered:
|
189
|
+
stmt = stmt.filter(and_(*self.filters))
|
184
190
|
|
185
|
-
|
191
|
+
if self._limit:
|
192
|
+
stmt = stmt.limit(self._limit)
|
193
|
+
|
194
|
+
self._clear_query_state()
|
195
|
+
|
196
|
+
return await self._execute_query_and_unique_data(stmt, load_all_relations)
|
197
|
+
finally:
|
198
|
+
self._clear_query_state()
|
199
|
+
|
200
|
+
def _clear_query_state(self):
|
201
|
+
"""Clear all query state after execution"""
|
202
|
+
self._filtered = False
|
203
|
+
self.filters = []
|
204
|
+
self._limit = None
|
186
205
|
|
187
206
|
async def paginate(self, limit: int = 10, offset: int = 0, load_all_relations: bool = False) -> List[ModelType]:
|
188
207
|
self._ensure_filtered()
|
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|
5
5
|
|
6
6
|
setup(
|
7
7
|
name="rb-commons",
|
8
|
-
version="0.4.
|
8
|
+
version="0.4.13",
|
9
9
|
author="Abdulvoris",
|
10
10
|
author_email="erkinovabdulvoris101@gmail.com",
|
11
11
|
description="Commons of project and simplified orm based on sqlalchemy.",
|
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
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|