django-bulk-hooks 0.1.167__py3-none-any.whl → 0.1.168__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.

Potentially problematic release.


This version of django-bulk-hooks might be problematic. Click here for more details.

@@ -66,7 +66,8 @@ def select_related(*related_fields):
66
66
 
67
67
  fetched = {}
68
68
  if ids_to_fetch:
69
- fetched = model_cls.objects.select_related(*related_fields).in_bulk(ids_to_fetch)
69
+ # Use the base manager to avoid recursion
70
+ fetched = model_cls._base_manager.select_related(*related_fields).in_bulk(ids_to_fetch)
70
71
 
71
72
  for obj in new_records:
72
73
  preloaded = fetched.get(obj.pk)
@@ -24,7 +24,8 @@ class HookQuerySet(models.QuerySet):
24
24
  objs = list(self)
25
25
  if not objs:
26
26
  return 0
27
- return self.model.objects.bulk_delete(objs)
27
+ # Call the base QuerySet implementation to avoid recursion
28
+ return super().bulk_delete(objs)
28
29
 
29
30
  @transaction.atomic
30
31
  def update(self, **kwargs):
@@ -36,7 +37,8 @@ class HookQuerySet(models.QuerySet):
36
37
  pks = [obj.pk for obj in instances]
37
38
 
38
39
  # Load originals for hook comparison and ensure they match the order of instances
39
- original_map = {obj.pk: obj for obj in model_cls.objects.filter(pk__in=pks)}
40
+ # Use the base manager to avoid recursion
41
+ original_map = {obj.pk: obj for obj in model_cls._base_manager.filter(pk__in=pks)}
40
42
  originals = [original_map.get(obj.pk) for obj in instances]
41
43
 
42
44
  # Apply field updates to instances
@@ -49,8 +51,8 @@ class HookQuerySet(models.QuerySet):
49
51
  engine.run(model_cls, BEFORE_UPDATE, instances, originals, ctx=ctx)
50
52
 
51
53
  # Use Django's built-in update logic directly
52
- queryset = self.model.objects.filter(pk__in=pks)
53
- update_count = queryset.update(**kwargs)
54
+ # Call the base QuerySet implementation to avoid recursion
55
+ update_count = super().update(**kwargs)
54
56
 
55
57
  # Run AFTER_UPDATE hooks
56
58
  engine.run(model_cls, AFTER_UPDATE, instances, originals, ctx=ctx)
@@ -202,9 +204,10 @@ class HookQuerySet(models.QuerySet):
202
204
 
203
205
  if not bypass_hooks:
204
206
  # Load originals for hook comparison and ensure they match the order of new instances
207
+ # Use the base manager to avoid recursion
205
208
  original_map = {
206
209
  obj.pk: obj
207
- for obj in model_cls.objects.filter(pk__in=[obj.pk for obj in objs])
210
+ for obj in model_cls._base_manager.filter(pk__in=[obj.pk for obj in objs])
208
211
  }
209
212
  originals = [original_map.get(obj.pk) for obj in objs]
210
213
 
@@ -274,9 +277,9 @@ class HookQuerySet(models.QuerySet):
274
277
 
275
278
  pks = [obj.pk for obj in objs if obj.pk is not None]
276
279
 
277
- # Use base manager for the actual deletion to prevent recursion
280
+ # Call the base QuerySet implementation to avoid recursion
278
281
  # The hooks have already been fired above, so we don't need them again
279
- model_cls._base_manager.filter(pk__in=pks).delete()
282
+ super().bulk_delete(objs, batch_size=batch_size)
280
283
 
281
284
  if not bypass_hooks:
282
285
  engine.run(model_cls, AFTER_DELETE, objs, ctx=ctx)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: django-bulk-hooks
3
- Version: 0.1.167
3
+ Version: 0.1.168
4
4
  Summary: Hook-style hooks for Django bulk operations like bulk_create and bulk_update.
5
5
  License: MIT
6
6
  Keywords: django,bulk,hooks
@@ -2,16 +2,16 @@ django_bulk_hooks/__init__.py,sha256=uUgpnb9AWjIAcWNpCMqBcOewSnpJjJYH6cjPbQkzoNU
2
2
  django_bulk_hooks/conditions.py,sha256=mTvlLcttixbXRkTSNZU5VewkPUavbXRuD2BkJbVWMkw,6041
3
3
  django_bulk_hooks/constants.py,sha256=3x1H1fSUUNo0DZONN7GUVDuySZctTR-jtByBHmAIX5w,303
4
4
  django_bulk_hooks/context.py,sha256=4IPuOX8TBAYBEMzN0RNHWgE6Giy2ZnR5uRXfd1cpIwk,1051
5
- django_bulk_hooks/decorators.py,sha256=tckDcxtOzKCbgvS9QydgeIAWTFDEl-ch3_Q--ruEGdQ,4831
5
+ django_bulk_hooks/decorators.py,sha256=WD7Jn7QAvY8F4wOsYlIpjoM9-FdHXSKB7hH9ot-lkYQ,4896
6
6
  django_bulk_hooks/engine.py,sha256=fqd32vwpNLoph2B6O7BW2eeja8yzUzenLx3Iwj2Mz_U,2964
7
7
  django_bulk_hooks/enums.py,sha256=Zo8_tJzuzZ2IKfVc7gZ-0tWPT8q1QhqZbAyoh9ZVJbs,381
8
8
  django_bulk_hooks/handler.py,sha256=xZt8iNdYF-ACz-MnKMY0co6scWINU5V5wC1lyDn844k,4854
9
9
  django_bulk_hooks/manager.py,sha256=nccIBEWLc9T18A97ZYT1KU4JzGSOvTjBdDOxS4D5bX0,5810
10
10
  django_bulk_hooks/models.py,sha256=5PBjBoGlHwAE5b4yaZ5kDjt5UtHfQp6pDrwB2XPs2tk,3850
11
11
  django_bulk_hooks/priority.py,sha256=HG_2D35nga68lBCZmSXTcplXrjFoRgZFRDOy4ROKonY,376
12
- django_bulk_hooks/queryset.py,sha256=pdxnZKJU6eMHT-bxp3s4r8MUwaTXgnIUxgyKvN-1WB8,24723
12
+ django_bulk_hooks/queryset.py,sha256=3U0VbfpbldMUoK_HAU1vx9OGGS8KQNuR2IeiENk6apM,24896
13
13
  django_bulk_hooks/registry.py,sha256=-mQBizJ06nz_tajZBinViKx_uP2Tbc1tIpTEMv7lwKA,705
14
- django_bulk_hooks-0.1.167.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
- django_bulk_hooks-0.1.167.dist-info/METADATA,sha256=2MGJzmRJUmyLiC0GBYC5ugEMwTFhnbISawDuYKV-I9E,6951
16
- django_bulk_hooks-0.1.167.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
- django_bulk_hooks-0.1.167.dist-info/RECORD,,
14
+ django_bulk_hooks-0.1.168.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
+ django_bulk_hooks-0.1.168.dist-info/METADATA,sha256=WS1Gswr9FoXiy8P5hSvQYRa252I0DnHtrVINLAk4wwY,6951
16
+ django_bulk_hooks-0.1.168.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
+ django_bulk_hooks-0.1.168.dist-info/RECORD,,