django-bulk-hooks 0.2.73__tar.gz → 0.2.74__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.
Potentially problematic release.
This version of django-bulk-hooks might be problematic. Click here for more details.
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/PKG-INFO +1 -1
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/dispatcher.py +25 -4
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/pyproject.toml +1 -1
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/LICENSE +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/README.md +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/__init__.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/changeset.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/conditions.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/constants.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/context.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/decorators.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/enums.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/factory.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/handler.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/helpers.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/manager.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/models.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/__init__.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/analyzer.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/bulk_executor.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/coordinator.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/field_utils.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/mti_handler.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/mti_plans.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/record_classifier.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/queryset.py +0 -0
- {django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/registry.py +0 -0
|
@@ -409,17 +409,38 @@ class HookDispatcher:
|
|
|
409
409
|
if hasattr(preloaded_obj, rel):
|
|
410
410
|
setattr(obj, rel, getattr(preloaded_obj, rel))
|
|
411
411
|
|
|
412
|
-
# Handle unsaved new_records by preloading their FK targets
|
|
412
|
+
# Handle unsaved new_records by preloading their FK targets (bulk query to avoid N+1)
|
|
413
413
|
if changeset.new_records:
|
|
414
|
+
# Collect FK IDs for each relationship from unsaved records
|
|
415
|
+
field_ids_map = {rel: set() for rel in relationship_list}
|
|
416
|
+
|
|
414
417
|
for obj in changeset.new_records:
|
|
415
418
|
if obj.pk is None: # Unsaved object
|
|
416
419
|
for rel in relationship_list:
|
|
417
420
|
if hasattr(obj, f'{rel}_id'):
|
|
418
421
|
rel_id = getattr(obj, f'{rel}_id')
|
|
419
422
|
if rel_id:
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
+
field_ids_map[rel].add(rel_id)
|
|
424
|
+
|
|
425
|
+
# Bulk load relationships for unsaved records
|
|
426
|
+
field_objects_map = {}
|
|
427
|
+
for rel, ids in field_ids_map.items():
|
|
428
|
+
if not ids:
|
|
429
|
+
continue
|
|
430
|
+
try:
|
|
431
|
+
rel_model = getattr(changeset.model_cls._meta.get_field(rel).remote_field, 'model')
|
|
432
|
+
field_objects_map[rel] = rel_model.objects.in_bulk(ids)
|
|
433
|
+
except Exception:
|
|
434
|
+
field_objects_map[rel] = {}
|
|
435
|
+
|
|
436
|
+
# Attach relationships to unsaved records
|
|
437
|
+
for obj in changeset.new_records:
|
|
438
|
+
if obj.pk is None: # Unsaved object
|
|
439
|
+
for rel in relationship_list:
|
|
440
|
+
rel_id = getattr(obj, f'{rel}_id', None)
|
|
441
|
+
if rel_id and rel in field_objects_map:
|
|
442
|
+
rel_obj = field_objects_map[rel].get(rel_id)
|
|
443
|
+
if rel_obj:
|
|
423
444
|
setattr(obj, rel, rel_obj)
|
|
424
445
|
|
|
425
446
|
def _preload_select_related_for_before_create(self, changeset, select_related_fields):
|
|
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
|
{django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/__init__.py
RENAMED
|
File without changes
|
{django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/analyzer.py
RENAMED
|
File without changes
|
{django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/bulk_executor.py
RENAMED
|
File without changes
|
{django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/coordinator.py
RENAMED
|
File without changes
|
{django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/field_utils.py
RENAMED
|
File without changes
|
{django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/mti_handler.py
RENAMED
|
File without changes
|
{django_bulk_hooks-0.2.73 → django_bulk_hooks-0.2.74}/django_bulk_hooks/operations/mti_plans.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|