django-bulk-hooks 0.1.255__py3-none-any.whl → 0.1.257__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 +32 -1
- {django_bulk_hooks-0.1.255.dist-info → django_bulk_hooks-0.1.257.dist-info}/METADATA +1 -1
- {django_bulk_hooks-0.1.255.dist-info → django_bulk_hooks-0.1.257.dist-info}/RECORD +5 -5
- {django_bulk_hooks-0.1.255.dist-info → django_bulk_hooks-0.1.257.dist-info}/LICENSE +0 -0
- {django_bulk_hooks-0.1.255.dist-info → django_bulk_hooks-0.1.257.dist-info}/WHEEL +0 -0
django_bulk_hooks/queryset.py
CHANGED
|
@@ -815,8 +815,9 @@ class HookQuerySetMixin:
|
|
|
815
815
|
)
|
|
816
816
|
|
|
817
817
|
logger.debug(
|
|
818
|
-
f"bulk_update {model_cls.__name__} bypass_hooks={bypass_hooks} objs={len(objs)}"
|
|
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
|
|
@@ -839,15 +840,41 @@ class HookQuerySetMixin:
|
|
|
839
840
|
# Handle auto_now fields like Django's update_or_create does
|
|
840
841
|
fields_set = set(fields)
|
|
841
842
|
pk_fields = model_cls._meta.pk_fields
|
|
843
|
+
auto_now_fields = []
|
|
844
|
+
logger.debug(f"Checking for auto_now fields in {model_cls.__name__}")
|
|
842
845
|
for field in model_cls._meta.local_concrete_fields:
|
|
843
846
|
# Only add auto_now fields (like updated_at) that aren't already in the fields list
|
|
844
847
|
# Don't include auto_now_add fields (like created_at) as they should only be set on creation
|
|
845
848
|
if hasattr(field, "auto_now") and field.auto_now:
|
|
849
|
+
logger.debug(f"Found auto_now field: {field.name}")
|
|
850
|
+
print(f"DEBUG: Found auto_now field: {field.name}")
|
|
846
851
|
if field.name not in fields_set and field.name not in pk_fields:
|
|
847
852
|
fields_set.add(field.name)
|
|
848
853
|
if field.name != field.attname:
|
|
849
854
|
fields_set.add(field.attname)
|
|
855
|
+
auto_now_fields.append(field.name)
|
|
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")
|
|
858
|
+
else:
|
|
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")
|
|
861
|
+
elif hasattr(field, "auto_now_add") and field.auto_now_add:
|
|
862
|
+
logger.debug(f"Found auto_now_add field: {field.name} (skipping)")
|
|
863
|
+
|
|
864
|
+
logger.debug(f"Auto_now fields detected: {auto_now_fields}")
|
|
865
|
+
print(f"DEBUG: Auto_now fields detected: {auto_now_fields}")
|
|
850
866
|
fields = list(fields_set)
|
|
867
|
+
|
|
868
|
+
# Set auto_now field values to current timestamp
|
|
869
|
+
if auto_now_fields:
|
|
870
|
+
from django.utils import timezone
|
|
871
|
+
current_time = timezone.now()
|
|
872
|
+
print(f"DEBUG: Setting auto_now fields {auto_now_fields} to current time: {current_time}")
|
|
873
|
+
logger.debug(f"Setting auto_now fields {auto_now_fields} to current time: {current_time}")
|
|
874
|
+
for obj in objs:
|
|
875
|
+
for field_name in auto_now_fields:
|
|
876
|
+
setattr(obj, field_name, current_time)
|
|
877
|
+
print(f"DEBUG: Set {field_name} to {current_time} for object {obj.pk}")
|
|
851
878
|
|
|
852
879
|
# Handle MTI models differently
|
|
853
880
|
if is_mti:
|
|
@@ -860,8 +887,10 @@ class HookQuerySetMixin:
|
|
|
860
887
|
if k not in ["bypass_hooks", "bypass_validation"]
|
|
861
888
|
}
|
|
862
889
|
logger.debug("Calling Django bulk_update")
|
|
890
|
+
print("DEBUG: Calling Django bulk_update")
|
|
863
891
|
# Build a per-object concrete value map to avoid leaking expressions into hooks
|
|
864
892
|
value_map = {}
|
|
893
|
+
logger.debug(f"Building value map for {len(objs)} objects with fields: {fields}")
|
|
865
894
|
for obj in objs:
|
|
866
895
|
if obj.pk is None:
|
|
867
896
|
continue
|
|
@@ -869,6 +898,8 @@ class HookQuerySetMixin:
|
|
|
869
898
|
for field_name in fields:
|
|
870
899
|
# Capture raw values assigned on the object (not expressions)
|
|
871
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]}")
|
|
872
903
|
if field_values:
|
|
873
904
|
value_map[obj.pk] = field_values
|
|
874
905
|
|
|
@@ -9,9 +9,9 @@ django_bulk_hooks/handler.py,sha256=Bx-W6yyiciKMyy-BRxUt3CmRPCrX9_LhQgU-5LaJTjg,
|
|
|
9
9
|
django_bulk_hooks/manager.py,sha256=nfWiwU5-yAoxdnQsUMohxtyCpkV0MBv6X3wmipr9eQY,3697
|
|
10
10
|
django_bulk_hooks/models.py,sha256=WtSfc4GBOG_oOt8n37cVvid0MtFIGze9JYKSixil2y0,4370
|
|
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=MhNibc-Z6D5CYTkIb2eW53eQNCtgo5AGgbV6jXTq2gQ,69765
|
|
13
13
|
django_bulk_hooks/registry.py,sha256=GRUTGVQEO2sdkC9OaZ9Q3U7mM-3Ix83uTyvrlTtpatw,1317
|
|
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.257.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
|
|
15
|
+
django_bulk_hooks-0.1.257.dist-info/METADATA,sha256=ixxx1gziIstq-MIU4097KRDITnCG0SlKj-zC1LieGzE,9061
|
|
16
|
+
django_bulk_hooks-0.1.257.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
17
|
+
django_bulk_hooks-0.1.257.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|