django-bulk-hooks 0.1.255__tar.gz → 0.1.256__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.255 → django_bulk_hooks-0.1.256}/PKG-INFO +1 -1
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/queryset.py +35 -12
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/pyproject.toml +1 -1
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/LICENSE +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/README.md +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/__init__.py +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/conditions.py +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/constants.py +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/context.py +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/decorators.py +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/engine.py +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/enums.py +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/handler.py +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/manager.py +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/models.py +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/priority.py +0 -0
- {django_bulk_hooks-0.1.255 → django_bulk_hooks-0.1.256}/django_bulk_hooks/registry.py +0 -0
|
@@ -815,7 +815,7 @@ 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
820
|
|
|
821
821
|
# Check for MTI
|
|
@@ -839,15 +839,35 @@ class HookQuerySetMixin:
|
|
|
839
839
|
# Handle auto_now fields like Django's update_or_create does
|
|
840
840
|
fields_set = set(fields)
|
|
841
841
|
pk_fields = model_cls._meta.pk_fields
|
|
842
|
+
auto_now_fields = []
|
|
843
|
+
logger.debug(f"Checking for auto_now fields in {model_cls.__name__}")
|
|
842
844
|
for field in model_cls._meta.local_concrete_fields:
|
|
843
845
|
# Only add auto_now fields (like updated_at) that aren't already in the fields list
|
|
844
846
|
# Don't include auto_now_add fields (like created_at) as they should only be set on creation
|
|
845
847
|
if hasattr(field, "auto_now") and field.auto_now:
|
|
848
|
+
logger.debug(f"Found auto_now field: {field.name}")
|
|
846
849
|
if field.name not in fields_set and field.name not in pk_fields:
|
|
847
850
|
fields_set.add(field.name)
|
|
848
851
|
if field.name != field.attname:
|
|
849
852
|
fields_set.add(field.attname)
|
|
853
|
+
auto_now_fields.append(field.name)
|
|
854
|
+
logger.debug(f"Added auto_now field {field.name} to fields list")
|
|
855
|
+
else:
|
|
856
|
+
logger.debug(f"Auto_now field {field.name} already in fields list or is PK")
|
|
857
|
+
elif hasattr(field, "auto_now_add") and field.auto_now_add:
|
|
858
|
+
logger.debug(f"Found auto_now_add field: {field.name} (skipping)")
|
|
859
|
+
|
|
860
|
+
logger.debug(f"Auto_now fields detected: {auto_now_fields}")
|
|
850
861
|
fields = list(fields_set)
|
|
862
|
+
|
|
863
|
+
# Set auto_now field values to current timestamp
|
|
864
|
+
if auto_now_fields:
|
|
865
|
+
from django.utils import timezone
|
|
866
|
+
current_time = timezone.now()
|
|
867
|
+
logger.debug(f"Setting auto_now fields {auto_now_fields} to current time: {current_time}")
|
|
868
|
+
for obj in objs:
|
|
869
|
+
for field_name in auto_now_fields:
|
|
870
|
+
setattr(obj, field_name, current_time)
|
|
851
871
|
|
|
852
872
|
# Handle MTI models differently
|
|
853
873
|
if is_mti:
|
|
@@ -860,17 +880,20 @@ class HookQuerySetMixin:
|
|
|
860
880
|
if k not in ["bypass_hooks", "bypass_validation"]
|
|
861
881
|
}
|
|
862
882
|
logger.debug("Calling Django bulk_update")
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
883
|
+
# Build a per-object concrete value map to avoid leaking expressions into hooks
|
|
884
|
+
value_map = {}
|
|
885
|
+
logger.debug(f"Building value map for {len(objs)} objects with fields: {fields}")
|
|
886
|
+
for obj in objs:
|
|
887
|
+
if obj.pk is None:
|
|
888
|
+
continue
|
|
889
|
+
field_values = {}
|
|
890
|
+
for field_name in fields:
|
|
891
|
+
# Capture raw values assigned on the object (not expressions)
|
|
892
|
+
field_values[field_name] = getattr(obj, field_name)
|
|
893
|
+
if field_name in auto_now_fields:
|
|
894
|
+
logger.debug(f"Object {obj.pk} {field_name}: {field_values[field_name]}")
|
|
895
|
+
if field_values:
|
|
896
|
+
value_map[obj.pk] = field_values
|
|
874
897
|
|
|
875
898
|
# Make the value map available to the subsequent update() call
|
|
876
899
|
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.256"
|
|
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
|