django-bulk-hooks 0.1.257__tar.gz → 0.1.259__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.

Files changed (17) hide show
  1. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/PKG-INFO +1 -1
  2. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/queryset.py +12 -4
  3. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/pyproject.toml +1 -1
  4. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/LICENSE +0 -0
  5. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/README.md +0 -0
  6. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/__init__.py +0 -0
  7. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/conditions.py +0 -0
  8. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/constants.py +0 -0
  9. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/context.py +0 -0
  10. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/decorators.py +0 -0
  11. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/engine.py +0 -0
  12. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/enums.py +0 -0
  13. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/handler.py +0 -0
  14. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/manager.py +0 -0
  15. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/models.py +0 -0
  16. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/priority.py +0 -0
  17. {django_bulk_hooks-0.1.257 → django_bulk_hooks-0.1.259}/django_bulk_hooks/registry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: django-bulk-hooks
3
- Version: 0.1.257
3
+ Version: 0.1.259
4
4
  Summary: Hook-style hooks for Django bulk operations like bulk_create and bulk_update.
5
5
  License: MIT
6
6
  Keywords: django,bulk,hooks
@@ -482,6 +482,11 @@ class HookQuerySetMixin:
482
482
  passed through to the correct logic. For MTI, only a subset of options may be supported.
483
483
  """
484
484
  model_cls = self.model
485
+
486
+ print(f"DEBUG: bulk_create called for {model_cls.__name__} with {len(objs)} objects")
487
+ print(f"DEBUG: update_conflicts={update_conflicts}, unique_fields={unique_fields}, update_fields={update_fields}")
488
+ logger.debug(f"bulk_create called for {model_cls.__name__} with {len(objs)} objects")
489
+ logger.debug(f"update_conflicts={update_conflicts}, unique_fields={unique_fields}, update_fields={update_fields}")
485
490
 
486
491
  # When you bulk insert you don't get the primary keys back (if it's an
487
492
  # autoincrement, except if can_return_rows_from_bulk_insert=True), so
@@ -614,15 +619,18 @@ class HookQuerySetMixin:
614
619
  key = tuple(getattr(db_record, field) for field in unique_fields)
615
620
  existing_db_map[key] = db_record
616
621
 
617
- # Preserve auto_now field values for existing records
622
+ # For existing records, set auto_now fields using Django's pre_save method
618
623
  for obj in existing_records:
619
624
  key = tuple(getattr(obj, field) for field in unique_fields)
620
625
  if key in existing_db_map:
621
- db_record = existing_db_map[key]
626
+ # Use Django's pre_save method to set auto_now fields (like updated_at)
622
627
  for field in model_cls._meta.local_fields:
623
628
  if hasattr(field, "auto_now") and field.auto_now:
624
- # Preserve the original updated_at timestamp
625
- setattr(obj, field.name, getattr(db_record, field.name))
629
+ field.pre_save(obj, add=False) # add=False for updates
630
+ print(f"DEBUG: Set {field.name} using pre_save for existing record {obj.pk}")
631
+ logger.debug(f"Set {field.name} using pre_save for existing record {obj.pk}")
632
+
633
+ # Remove duplicate code since we're now handling this above
626
634
 
627
635
  # CRITICAL: Exclude auto_now fields from update_fields for existing records
628
636
  # This prevents Django from including them in the ON CONFLICT DO UPDATE clause
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "django-bulk-hooks"
3
- version = "0.1.257"
3
+ version = "0.1.259"
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"