django-bulk-hooks 0.1.256__tar.gz → 0.1.257__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.1.256 → django_bulk_hooks-0.1.257}/PKG-INFO +1 -1
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/queryset.py +22 -14
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/pyproject.toml +1 -1
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/LICENSE +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/README.md +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/__init__.py +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/conditions.py +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/constants.py +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/context.py +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/decorators.py +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/engine.py +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/enums.py +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/handler.py +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/manager.py +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/models.py +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/priority.py +0 -0
- {django_bulk_hooks-0.1.256 → django_bulk_hooks-0.1.257}/django_bulk_hooks/registry.py +0 -0
|
@@ -817,6 +817,7 @@ class HookQuerySetMixin:
|
|
|
817
817
|
logger.debug(
|
|
818
818
|
f"bulk_update {model_cls.__name__} bypass_hooks={bypass_hooks} objs={len(objs)} fields={fields}"
|
|
819
819
|
)
|
|
820
|
+
print(f"DEBUG: bulk_update {model_cls.__name__} bypass_hooks={bypass_hooks} objs={len(objs)} fields={fields}")
|
|
820
821
|
|
|
821
822
|
# Check for MTI
|
|
822
823
|
is_mti = False
|
|
@@ -846,28 +847,34 @@ class HookQuerySetMixin:
|
|
|
846
847
|
# Don't include auto_now_add fields (like created_at) as they should only be set on creation
|
|
847
848
|
if hasattr(field, "auto_now") and field.auto_now:
|
|
848
849
|
logger.debug(f"Found auto_now field: {field.name}")
|
|
850
|
+
print(f"DEBUG: Found auto_now field: {field.name}")
|
|
849
851
|
if field.name not in fields_set and field.name not in pk_fields:
|
|
850
852
|
fields_set.add(field.name)
|
|
851
853
|
if field.name != field.attname:
|
|
852
854
|
fields_set.add(field.attname)
|
|
853
855
|
auto_now_fields.append(field.name)
|
|
854
856
|
logger.debug(f"Added auto_now field {field.name} to fields list")
|
|
857
|
+
print(f"DEBUG: Added auto_now field {field.name} to fields list")
|
|
855
858
|
else:
|
|
856
859
|
logger.debug(f"Auto_now field {field.name} already in fields list or is PK")
|
|
860
|
+
print(f"DEBUG: Auto_now field {field.name} already in fields list or is PK")
|
|
857
861
|
elif hasattr(field, "auto_now_add") and field.auto_now_add:
|
|
858
862
|
logger.debug(f"Found auto_now_add field: {field.name} (skipping)")
|
|
859
863
|
|
|
860
864
|
logger.debug(f"Auto_now fields detected: {auto_now_fields}")
|
|
865
|
+
print(f"DEBUG: Auto_now fields detected: {auto_now_fields}")
|
|
861
866
|
fields = list(fields_set)
|
|
862
867
|
|
|
863
868
|
# Set auto_now field values to current timestamp
|
|
864
869
|
if auto_now_fields:
|
|
865
870
|
from django.utils import timezone
|
|
866
871
|
current_time = timezone.now()
|
|
872
|
+
print(f"DEBUG: Setting auto_now fields {auto_now_fields} to current time: {current_time}")
|
|
867
873
|
logger.debug(f"Setting auto_now fields {auto_now_fields} to current time: {current_time}")
|
|
868
874
|
for obj in objs:
|
|
869
875
|
for field_name in auto_now_fields:
|
|
870
876
|
setattr(obj, field_name, current_time)
|
|
877
|
+
print(f"DEBUG: Set {field_name} to {current_time} for object {obj.pk}")
|
|
871
878
|
|
|
872
879
|
# Handle MTI models differently
|
|
873
880
|
if is_mti:
|
|
@@ -880,20 +887,21 @@ class HookQuerySetMixin:
|
|
|
880
887
|
if k not in ["bypass_hooks", "bypass_validation"]
|
|
881
888
|
}
|
|
882
889
|
logger.debug("Calling Django bulk_update")
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
890
|
+
print("DEBUG: Calling Django bulk_update")
|
|
891
|
+
# Build a per-object concrete value map to avoid leaking expressions into hooks
|
|
892
|
+
value_map = {}
|
|
893
|
+
logger.debug(f"Building value map for {len(objs)} objects with fields: {fields}")
|
|
894
|
+
for obj in objs:
|
|
895
|
+
if obj.pk is None:
|
|
896
|
+
continue
|
|
897
|
+
field_values = {}
|
|
898
|
+
for field_name in fields:
|
|
899
|
+
# Capture raw values assigned on the object (not expressions)
|
|
900
|
+
field_values[field_name] = getattr(obj, field_name)
|
|
901
|
+
if field_name in auto_now_fields:
|
|
902
|
+
logger.debug(f"Object {obj.pk} {field_name}: {field_values[field_name]}")
|
|
903
|
+
if field_values:
|
|
904
|
+
value_map[obj.pk] = field_values
|
|
897
905
|
|
|
898
906
|
# Make the value map available to the subsequent update() call
|
|
899
907
|
if value_map:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "django-bulk-hooks"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.257"
|
|
4
4
|
description = "Hook-style hooks for Django bulk operations like bulk_create and bulk_update."
|
|
5
5
|
authors = ["Konrad Beck <konrad.beck@merchantcapital.co.za>"]
|
|
6
6
|
readme = "README.md"
|
|
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
|