django-bulk-hooks 0.1.132__py3-none-any.whl → 0.1.133__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 +43 -13
- {django_bulk_hooks-0.1.132.dist-info → django_bulk_hooks-0.1.133.dist-info}/METADATA +1 -1
- {django_bulk_hooks-0.1.132.dist-info → django_bulk_hooks-0.1.133.dist-info}/RECORD +5 -5
- {django_bulk_hooks-0.1.132.dist-info → django_bulk_hooks-0.1.133.dist-info}/LICENSE +0 -0
- {django_bulk_hooks-0.1.132.dist-info → django_bulk_hooks-0.1.133.dist-info}/WHEEL +0 -0
django_bulk_hooks/queryset.py
CHANGED
|
@@ -371,20 +371,50 @@ class HookQuerySet(models.QuerySet):
|
|
|
371
371
|
all_child_objects.append(child_obj)
|
|
372
372
|
print(f"DEBUG: Created {len(all_child_objects)} child objects")
|
|
373
373
|
|
|
374
|
-
# Step 2.5:
|
|
374
|
+
# Step 2.5: Use Django's internal _batched_insert method directly
|
|
375
375
|
if all_child_objects:
|
|
376
|
-
print(f"DEBUG:
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
376
|
+
print(f"DEBUG: Using Django's internal _batched_insert for {len(all_child_objects)} child objects")
|
|
377
|
+
|
|
378
|
+
# Get the base manager's queryset
|
|
379
|
+
base_qs = child_model._base_manager.using(self.db)
|
|
380
|
+
|
|
381
|
+
# Use Django's internal _batched_insert method directly
|
|
382
|
+
# This bypasses the MTI check but uses Django's optimized bulk insert
|
|
383
|
+
opts = child_model._meta
|
|
384
|
+
fields = [f for f in opts.concrete_fields if not f.generated]
|
|
385
|
+
|
|
386
|
+
# Prepare objects for bulk insert (same logic as Django's bulk_create)
|
|
387
|
+
objs_with_pk, objs_without_pk = base_qs._prepare_for_bulk_create(all_child_objects)
|
|
388
|
+
|
|
389
|
+
with transaction.atomic(using=self.db, savepoint=False):
|
|
390
|
+
if objs_with_pk:
|
|
391
|
+
returned_columns = base_qs._batched_insert(
|
|
392
|
+
objs_with_pk,
|
|
393
|
+
fields,
|
|
394
|
+
batch_size=None,
|
|
395
|
+
)
|
|
396
|
+
for obj_with_pk, results in zip(objs_with_pk, returned_columns):
|
|
397
|
+
for result, field in zip(results, opts.db_returning_fields):
|
|
398
|
+
if field != opts.pk:
|
|
399
|
+
setattr(obj_with_pk, field.attname, result)
|
|
400
|
+
for obj_with_pk in objs_with_pk:
|
|
401
|
+
obj_with_pk._state.adding = False
|
|
402
|
+
obj_with_pk._state.db = self.db
|
|
403
|
+
|
|
404
|
+
if objs_without_pk:
|
|
405
|
+
fields = [f for f in fields if not isinstance(f, AutoField)]
|
|
406
|
+
returned_columns = base_qs._batched_insert(
|
|
407
|
+
objs_without_pk,
|
|
408
|
+
fields,
|
|
409
|
+
batch_size=None,
|
|
410
|
+
)
|
|
411
|
+
for obj_without_pk, results in zip(objs_without_pk, returned_columns):
|
|
412
|
+
for result, field in zip(results, opts.db_returning_fields):
|
|
413
|
+
setattr(obj_without_pk, field.attname, result)
|
|
414
|
+
obj_without_pk._state.adding = False
|
|
415
|
+
obj_without_pk._state.db = self.db
|
|
416
|
+
|
|
417
|
+
print(f"DEBUG: Successfully bulk created child objects using Django's internal methods")
|
|
388
418
|
|
|
389
419
|
# Step 3: Update original objects with generated PKs and state
|
|
390
420
|
pk_field_name = child_model._meta.pk.name
|
|
@@ -9,9 +9,9 @@ django_bulk_hooks/handler.py,sha256=xZt8iNdYF-ACz-MnKMY0co6scWINU5V5wC1lyDn844k,
|
|
|
9
9
|
django_bulk_hooks/manager.py,sha256=r54ct3S6AcqME2OsX-jPF944CEKcoSIW3qiAx_NwUaw,2801
|
|
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=0ocXCPiFDH-16RSj6glNHfuebixDuvVF36svqtjIgLA,21680
|
|
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.133.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
|
|
15
|
+
django_bulk_hooks-0.1.133.dist-info/METADATA,sha256=COVQFxmpj6XJ1v56jd3jWDeOptUdWKidTrwM1Vx9Zjs,6951
|
|
16
|
+
django_bulk_hooks-0.1.133.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
17
|
+
django_bulk_hooks-0.1.133.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|