django-bulk-hooks 0.1.119__py3-none-any.whl → 0.1.120__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.
- django_bulk_hooks/queryset.py +18 -1
- {django_bulk_hooks-0.1.119.dist-info → django_bulk_hooks-0.1.120.dist-info}/METADATA +1 -1
- {django_bulk_hooks-0.1.119.dist-info → django_bulk_hooks-0.1.120.dist-info}/RECORD +5 -5
- {django_bulk_hooks-0.1.119.dist-info → django_bulk_hooks-0.1.120.dist-info}/LICENSE +0 -0
- {django_bulk_hooks-0.1.119.dist-info → django_bulk_hooks-0.1.120.dist-info}/WHEEL +0 -0
django_bulk_hooks/queryset.py
CHANGED
|
@@ -48,7 +48,7 @@ class HookQuerySet(models.QuerySet):
|
|
|
48
48
|
for obj in instances:
|
|
49
49
|
for field, value in kwargs.items():
|
|
50
50
|
setattr(obj, field, value)
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
# Run BEFORE_UPDATE hooks
|
|
53
53
|
ctx = HookContext(model_cls)
|
|
54
54
|
engine.run(model_cls, BEFORE_UPDATE, instances, originals, ctx=ctx)
|
|
@@ -120,6 +120,7 @@ class HookQuerySet(models.QuerySet):
|
|
|
120
120
|
else:
|
|
121
121
|
# For single-table models, use Django's built-in bulk_create
|
|
122
122
|
# but we need to call it on the base manager to avoid recursion
|
|
123
|
+
|
|
123
124
|
result = model_cls._base_manager.bulk_create(
|
|
124
125
|
objs,
|
|
125
126
|
batch_size=batch_size,
|
|
@@ -175,6 +176,7 @@ class HookQuerySet(models.QuerySet):
|
|
|
175
176
|
|
|
176
177
|
for i in range(0, len(objs), self.CHUNK_SIZE):
|
|
177
178
|
chunk = objs[i : i + self.CHUNK_SIZE]
|
|
179
|
+
|
|
178
180
|
# Call the base implementation to avoid re-triggering this method
|
|
179
181
|
super().bulk_update(chunk, fields, **kwargs)
|
|
180
182
|
|
|
@@ -336,6 +338,7 @@ class HookQuerySet(models.QuerySet):
|
|
|
336
338
|
created = self._mti_bulk_create(child_objects, inheritance_chain, **kwargs)
|
|
337
339
|
else:
|
|
338
340
|
# Single-table, safe to use bulk_create
|
|
341
|
+
|
|
339
342
|
child_manager = child_model._base_manager
|
|
340
343
|
child_manager._for_write = True
|
|
341
344
|
created = child_manager.bulk_create(child_objects, **kwargs)
|
|
@@ -364,6 +367,13 @@ class HookQuerySet(models.QuerySet):
|
|
|
364
367
|
):
|
|
365
368
|
setattr(parent_obj, field.name, current_parent)
|
|
366
369
|
break
|
|
370
|
+
|
|
371
|
+
# Handle auto_now_add and auto_now fields like Django does
|
|
372
|
+
for field in parent_model._meta.local_fields:
|
|
373
|
+
if field.__class__.pre_save is not field.__class__.__bases__[0].pre_save:
|
|
374
|
+
# This field has a custom pre_save method (like auto_now_add/auto_now)
|
|
375
|
+
field.pre_save(parent_obj, add=True)
|
|
376
|
+
|
|
367
377
|
return parent_obj
|
|
368
378
|
|
|
369
379
|
def _create_child_instance(self, source_obj, child_model, parent_instances):
|
|
@@ -379,4 +389,11 @@ class HookQuerySet(models.QuerySet):
|
|
|
379
389
|
parent_link = child_model._meta.get_ancestor_link(parent_model)
|
|
380
390
|
if parent_link:
|
|
381
391
|
setattr(child_obj, parent_link.name, parent_instance)
|
|
392
|
+
|
|
393
|
+
# Handle auto_now_add and auto_now fields like Django does
|
|
394
|
+
for field in child_model._meta.local_fields:
|
|
395
|
+
if field.__class__.pre_save is not field.__class__.__bases__[0].pre_save:
|
|
396
|
+
# This field has a custom pre_save method (like auto_now_add/auto_now)
|
|
397
|
+
field.pre_save(child_obj, add=True)
|
|
398
|
+
|
|
382
399
|
return child_obj
|
|
@@ -9,9 +9,9 @@ django_bulk_hooks/handler.py,sha256=xZt8iNdYF-ACz-MnKMY0co6scWINU5V5wC1lyDn844k,
|
|
|
9
9
|
django_bulk_hooks/manager.py,sha256=DjEW-nZjhlBW6cp8GRPl6xOSsAmmquP0Y-QyCZMoSHo,6946
|
|
10
10
|
django_bulk_hooks/models.py,sha256=7RG7GrOdHXFjGVPV4FPRZVNMIHHW-hMCi6hn9LH_hVI,3331
|
|
11
11
|
django_bulk_hooks/priority.py,sha256=HG_2D35nga68lBCZmSXTcplXrjFoRgZFRDOy4ROKonY,376
|
|
12
|
-
django_bulk_hooks/queryset.py,sha256=
|
|
12
|
+
django_bulk_hooks/queryset.py,sha256=zt6XToualdlA1MK_VT2ILovblZaKtul_elZSXnpk8hE,15885
|
|
13
13
|
django_bulk_hooks/registry.py,sha256=-mQBizJ06nz_tajZBinViKx_uP2Tbc1tIpTEMv7lwKA,705
|
|
14
|
-
django_bulk_hooks-0.1.
|
|
15
|
-
django_bulk_hooks-0.1.
|
|
16
|
-
django_bulk_hooks-0.1.
|
|
17
|
-
django_bulk_hooks-0.1.
|
|
14
|
+
django_bulk_hooks-0.1.120.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
|
|
15
|
+
django_bulk_hooks-0.1.120.dist-info/METADATA,sha256=VE12uNcfnuW92FhLRv9KealQLko0FPpy0OQKsDwJ6II,6951
|
|
16
|
+
django_bulk_hooks-0.1.120.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
17
|
+
django_bulk_hooks-0.1.120.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|