django-bulk-hooks 0.1.192__py3-none-any.whl → 0.1.194__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.

@@ -14,7 +14,7 @@ from django_bulk_hooks.constants import (
14
14
  VALIDATE_UPDATE,
15
15
  )
16
16
  from django_bulk_hooks.context import HookContext
17
- from django.db.models import When, Value, Case
17
+ from django.db.models import When, Value, Case, Field
18
18
 
19
19
 
20
20
  class HookQuerySetMixin:
@@ -226,6 +226,18 @@ class HookQuerySetMixin:
226
226
  fields_set.update(modified_fields)
227
227
  fields = list(fields_set)
228
228
 
229
+ # Handle auto_now fields like Django's update_or_create does
230
+ fields_set = set(fields)
231
+ pk_fields = model_cls._meta.pk_fields
232
+ for field in model_cls._meta.local_concrete_fields:
233
+ # Only add auto_now and auto_now_add fields that aren't already in the fields list
234
+ if (hasattr(field, "auto_now") and field.auto_now) or (hasattr(field, "auto_now_add") and field.auto_now_add):
235
+ if field.name not in fields_set and field.name not in pk_fields:
236
+ fields_set.add(field.name)
237
+ if field.name != field.attname:
238
+ fields_set.add(field.attname)
239
+ fields = list(fields_set)
240
+
229
241
  # Handle MTI models differently
230
242
  if is_mti:
231
243
  result = self._mti_bulk_update(objs, fields, **kwargs)
@@ -557,6 +569,12 @@ class HookQuerySetMixin:
557
569
  "Inheritance chain too deep - possible infinite recursion detected"
558
570
  )
559
571
 
572
+ # Handle auto_now fields by calling pre_save on objects
573
+ for obj in objs:
574
+ for field in model_cls._meta.local_fields:
575
+ if hasattr(field, "auto_now") and field.auto_now:
576
+ field.pre_save(obj, add=False)
577
+
560
578
  # Group fields by model in the inheritance chain
561
579
  field_groups = {}
562
580
  for field_name in fields:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: django-bulk-hooks
3
- Version: 0.1.192
3
+ Version: 0.1.194
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
@@ -9,9 +9,9 @@ django_bulk_hooks/handler.py,sha256=xZt8iNdYF-ACz-MnKMY0co6scWINU5V5wC1lyDn844k,
9
9
  django_bulk_hooks/manager.py,sha256=nfWiwU5-yAoxdnQsUMohxtyCpkV0MBv6X3wmipr9eQY,3697
10
10
  django_bulk_hooks/models.py,sha256=7fnx5xd4HWXfLVlFhhiRzR92JRWFEuxgk6aSWLEsyJg,3996
11
11
  django_bulk_hooks/priority.py,sha256=HG_2D35nga68lBCZmSXTcplXrjFoRgZFRDOy4ROKonY,376
12
- django_bulk_hooks/queryset.py,sha256=G8tzhFM8tirPXLJi0KwGWuybugboJoix21z7j_lPqJ4,27908
12
+ django_bulk_hooks/queryset.py,sha256=RSIPK-6w1_lNgfWOMJS5oSwjT9M5JP1vCquWCIc9CXY,28872
13
13
  django_bulk_hooks/registry.py,sha256=-mQBizJ06nz_tajZBinViKx_uP2Tbc1tIpTEMv7lwKA,705
14
- django_bulk_hooks-0.1.192.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
- django_bulk_hooks-0.1.192.dist-info/METADATA,sha256=4QTA06jIRiiURXxuvwnQVLf6qTURJD48Zadn9PufPAk,7418
16
- django_bulk_hooks-0.1.192.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
- django_bulk_hooks-0.1.192.dist-info/RECORD,,
14
+ django_bulk_hooks-0.1.194.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
+ django_bulk_hooks-0.1.194.dist-info/METADATA,sha256=1_QoRmDbddARMGeiiuQ28XxILRd7UZacnheHjJ3fKB0,7418
16
+ django_bulk_hooks-0.1.194.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
+ django_bulk_hooks-0.1.194.dist-info/RECORD,,