django-bulk-hooks 0.1.197__tar.gz → 0.1.199__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.197 → django_bulk_hooks-0.1.199}/PKG-INFO +1 -1
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/queryset.py +24 -1
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/pyproject.toml +1 -1
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/LICENSE +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/README.md +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/__init__.py +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/conditions.py +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/constants.py +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/context.py +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/decorators.py +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/engine.py +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/enums.py +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/handler.py +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/manager.py +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/models.py +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/priority.py +0 -0
- {django_bulk_hooks-0.1.197 → django_bulk_hooks-0.1.199}/django_bulk_hooks/registry.py +0 -0
|
@@ -584,14 +584,30 @@ class HookQuerySetMixin:
|
|
|
584
584
|
if hasattr(field, "auto_now") and field.auto_now:
|
|
585
585
|
auto_now_fields.append(field.name)
|
|
586
586
|
print(f"DEBUG: Found auto_now field '{field.name}' on model {model.__name__}")
|
|
587
|
+
old_value = getattr(obj, field.name, None)
|
|
587
588
|
field.pre_save(obj, add=False)
|
|
589
|
+
new_value = getattr(obj, field.name, None)
|
|
590
|
+
print(f"DEBUG: {field.name} value changed from {old_value} to {new_value}")
|
|
588
591
|
|
|
589
592
|
if not auto_now_fields:
|
|
590
593
|
print(f"DEBUG: No auto_now fields found on model {model.__name__}")
|
|
591
594
|
|
|
595
|
+
# Add auto_now fields to the fields list so they get updated in the database
|
|
596
|
+
auto_now_fields = set()
|
|
597
|
+
for model in inheritance_chain:
|
|
598
|
+
for field in model._meta.local_fields:
|
|
599
|
+
if hasattr(field, "auto_now") and field.auto_now:
|
|
600
|
+
auto_now_fields.add(field.name)
|
|
601
|
+
|
|
602
|
+
# Combine original fields with auto_now fields
|
|
603
|
+
all_fields = list(fields) + list(auto_now_fields)
|
|
604
|
+
print(f"DEBUG: Original fields: {fields}")
|
|
605
|
+
print(f"DEBUG: Auto_now fields found: {auto_now_fields}")
|
|
606
|
+
print(f"DEBUG: All fields to update: {all_fields}")
|
|
607
|
+
|
|
592
608
|
# Group fields by model in the inheritance chain
|
|
593
609
|
field_groups = {}
|
|
594
|
-
for field_name in
|
|
610
|
+
for field_name in all_fields:
|
|
595
611
|
field = model_cls._meta.get_field(field_name)
|
|
596
612
|
# Find which model in the inheritance chain this field belongs to
|
|
597
613
|
for model in inheritance_chain:
|
|
@@ -649,6 +665,8 @@ class HookQuerySetMixin:
|
|
|
649
665
|
if not model_fields:
|
|
650
666
|
continue
|
|
651
667
|
|
|
668
|
+
print(f"DEBUG: Updating model {model.__name__} with fields: {model_fields}")
|
|
669
|
+
|
|
652
670
|
if model == inheritance_chain[0]:
|
|
653
671
|
# Root model - use primary keys directly
|
|
654
672
|
pks = root_pks
|
|
@@ -674,6 +692,8 @@ class HookQuerySetMixin:
|
|
|
674
692
|
# Check if records exist
|
|
675
693
|
existing_count = base_qs.filter(**{f"{filter_field}__in": pks}).count()
|
|
676
694
|
|
|
695
|
+
print(f"DEBUG: Found {existing_count} existing records for model {model.__name__}")
|
|
696
|
+
|
|
677
697
|
if existing_count == 0:
|
|
678
698
|
continue
|
|
679
699
|
|
|
@@ -683,6 +703,8 @@ class HookQuerySetMixin:
|
|
|
683
703
|
field = model._meta.get_field(field_name)
|
|
684
704
|
when_statements = []
|
|
685
705
|
|
|
706
|
+
print(f"DEBUG: Processing field '{field_name}' for model {model.__name__}")
|
|
707
|
+
|
|
686
708
|
for pk, obj in zip(pks, batch):
|
|
687
709
|
# Check both pk and id attributes for the object
|
|
688
710
|
obj_pk = getattr(obj, 'pk', None)
|
|
@@ -692,6 +714,7 @@ class HookQuerySetMixin:
|
|
|
692
714
|
if obj_pk is None:
|
|
693
715
|
continue
|
|
694
716
|
value = getattr(obj, field_name)
|
|
717
|
+
print(f"DEBUG: Setting {field_name} = {value} for object {obj_pk}")
|
|
695
718
|
when_statements.append(When(**{filter_field: pk}, then=Value(value, output_field=field)))
|
|
696
719
|
|
|
697
720
|
case_statements[field_name] = Case(*when_statements, output_field=field)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "django-bulk-hooks"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.199"
|
|
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
|