accrete 0.0.91__py3-none-any.whl → 0.0.92__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.
accrete/annotation.py CHANGED
@@ -1,4 +1,4 @@
1
- from django.db.models import Field
1
+ from django.db.models import Field, Subquery, OuterRef
2
2
  from django.db.models.expressions import Func
3
3
  from django.db.models.aggregates import Aggregate
4
4
 
@@ -34,10 +34,13 @@ class AnnotationModelMixin:
34
34
 
35
35
  class AnnotationManagerMixin:
36
36
 
37
- def get_annotations(self):
37
+ def get_annotations(self, queryset):
38
38
  if not hasattr(self.model, 'get_annotations'):
39
39
  return {}
40
40
  return {
41
- annotation['name']: annotation['annotation'].function
41
+ annotation['name']: Subquery(
42
+ queryset.annotate(**{
43
+ annotation['name']: annotation['annotation'].function
44
+ }).filter(pk=OuterRef('pk')).values(annotation['name'])[:1])
42
45
  for annotation in self.model.get_annotations()
43
46
  }
accrete/managers.py CHANGED
@@ -9,7 +9,7 @@ class TenantManager(models.Manager, AnnotationManagerMixin):
9
9
  queryset = super().get_queryset()
10
10
  if tenant := get_tenant():
11
11
  queryset = queryset.filter(tenant=tenant)
12
- return queryset.annotate(**self.get_annotations())
12
+ return queryset.annotate(**self.get_annotations(queryset))
13
13
 
14
14
  def bulk_create(
15
15
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: accrete
3
- Version: 0.0.91
3
+ Version: 0.0.92
4
4
  Summary: Django Shared Schema Multi Tenant
5
5
  Author-email: Benedikt Jilek <benedikt.jilek@pm.me>
6
6
  License: Copyright (c) 2023 Benedikt Jilek
@@ -1,10 +1,10 @@
1
1
  accrete/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  accrete/admin.py,sha256=MUYUmCFlGYPowiXTbwl4_Q6Cq0-neiL53WW4P76JCLs,1174
3
- accrete/annotation.py,sha256=P85kNgf_ka3U8i5cwaiKaAiSm21U-xY9PKmXMZR2ulU,1160
3
+ accrete/annotation.py,sha256=GCpTTX3fJH9w2vOOOydKcAALdEd1gRNjh_Ws9LkJ4aA,1355
4
4
  accrete/apps.py,sha256=F7ynMLHJr_6bRujWtZVUzCliY2CGKiDvyUmL4F68L2E,146
5
5
  accrete/config.py,sha256=eJUbvyBO3DvAD6xkVKjTAzlXy7V7EK9bVyb91girfUs,299
6
6
  accrete/forms.py,sha256=2vUh80qNvPDD8Zl3agKBSJEQeY7bXVLOx_SAB34wf8E,1359
7
- accrete/managers.py,sha256=CaIJLeBry4NYIXaVUrdUjp7zx4sEWgv-1-ssI1m-EOs,1156
7
+ accrete/managers.py,sha256=vODaKmWPvgfRoYXbQ_JD-pRjd2QWM_a9Gjkllrua0WE,1164
8
8
  accrete/middleware.py,sha256=IABs2pAV-kXjp3n5_Wsc7reXGjU5FhmCbvFB8cC4ZRM,3422
9
9
  accrete/models.py,sha256=xliEVR0XPW46ZDJn3-F46s54tG9dxz7BVLbkq1pC144,5434
10
10
  accrete/storage.py,sha256=z7pHdQFw0hFGrrbfqIh7KFxabQ_JGqoPebmiX9TLmeU,1254
@@ -232,7 +232,7 @@ accrete/utils/dates.py,sha256=apM6kt6JhGrKgoT0jfav1W-8AUVTxNc9xt3fJQ2n0JI,1492
232
232
  accrete/utils/forms.py,sha256=IvxbXNpSd4a-JBgsTJhs2GHe-DCRWX-xnVPRcoiCzbI,3104
233
233
  accrete/utils/http.py,sha256=sUDwa9hpYAle7d0iJxIA5wQk2mK2BMENo7JyFBSPxKc,4475
234
234
  accrete/utils/models.py,sha256=EEhv7-sQVtQD24PEb3XcDUAh3VVhVFoMMLyFrDjGEaI,706
235
- accrete-0.0.91.dist-info/METADATA,sha256=k3qGFn3c_K4AyeJlP31KEul9lkm9cG_fdxZBY1CIilY,4952
236
- accrete-0.0.91.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
237
- accrete-0.0.91.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
238
- accrete-0.0.91.dist-info/RECORD,,
235
+ accrete-0.0.92.dist-info/METADATA,sha256=qQWTwFVcTYzWGNz5a5Zl4IRkzL8oZRiLywbh4ueADSc,4952
236
+ accrete-0.0.92.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
237
+ accrete-0.0.92.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
238
+ accrete-0.0.92.dist-info/RECORD,,