django-bulk-hooks 0.1.201__py3-none-any.whl → 0.1.202__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.
- django_bulk_hooks/queryset.py +15 -16
- {django_bulk_hooks-0.1.201.dist-info → django_bulk_hooks-0.1.202.dist-info}/METADATA +1 -1
- {django_bulk_hooks-0.1.201.dist-info → django_bulk_hooks-0.1.202.dist-info}/RECORD +5 -5
- {django_bulk_hooks-0.1.201.dist-info → django_bulk_hooks-0.1.202.dist-info}/LICENSE +0 -0
- {django_bulk_hooks-0.1.201.dist-info → django_bulk_hooks-0.1.202.dist-info}/WHEEL +0 -0
django_bulk_hooks/queryset.py
CHANGED
|
@@ -321,35 +321,34 @@ class HookQuerySetMixin:
|
|
|
321
321
|
"""
|
|
322
322
|
Detect fields that were modified during BEFORE_UPDATE hooks by comparing
|
|
323
323
|
new instances with their original values.
|
|
324
|
+
Optimized to avoid dereferencing related objects which can trigger queries.
|
|
324
325
|
"""
|
|
325
326
|
if not original_instances:
|
|
326
327
|
return set()
|
|
327
328
|
|
|
328
329
|
modified_fields = set()
|
|
329
330
|
|
|
330
|
-
# Since original_instances is
|
|
331
|
+
# Since original_instances is ordered to match new_instances, we can zip them directly
|
|
331
332
|
for new_instance, original in zip(new_instances, original_instances):
|
|
332
|
-
if new_instance
|
|
333
|
+
if new_instance is None or original is None:
|
|
333
334
|
continue
|
|
334
335
|
|
|
335
|
-
#
|
|
336
|
-
for field in new_instance._meta.
|
|
337
|
-
if field.
|
|
336
|
+
# Only check local concrete fields; skip PK and many-to-many
|
|
337
|
+
for field in new_instance._meta.local_concrete_fields:
|
|
338
|
+
if field.primary_key:
|
|
338
339
|
continue
|
|
339
340
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
# For foreign keys, compare the pk values
|
|
346
|
-
new_pk = new_value.pk if new_value else None
|
|
347
|
-
original_pk = original_value.pk if original_value else None
|
|
348
|
-
if new_pk != original_pk:
|
|
341
|
+
if getattr(field, "remote_field", None):
|
|
342
|
+
# ForeignKey/OneToOne: compare the raw id values via attname to avoid fetching related objects
|
|
343
|
+
new_id = getattr(new_instance, field.attname, None)
|
|
344
|
+
old_id = getattr(original, field.attname, None)
|
|
345
|
+
if new_id != old_id:
|
|
349
346
|
modified_fields.add(field.name)
|
|
350
347
|
else:
|
|
351
|
-
#
|
|
352
|
-
if
|
|
348
|
+
# Regular value fields
|
|
349
|
+
new_value = getattr(new_instance, field.attname if hasattr(field, "attname") else field.name)
|
|
350
|
+
old_value = getattr(original, field.attname if hasattr(field, "attname") else field.name)
|
|
351
|
+
if new_value != old_value:
|
|
353
352
|
modified_fields.add(field.name)
|
|
354
353
|
|
|
355
354
|
return modified_fields
|
|
@@ -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=
|
|
12
|
+
django_bulk_hooks/queryset.py,sha256=NRbkJL9D_V97W76UxodMye1zaB0nJZGjMmv0SR0QLzs,36628
|
|
13
13
|
django_bulk_hooks/registry.py,sha256=-mQBizJ06nz_tajZBinViKx_uP2Tbc1tIpTEMv7lwKA,705
|
|
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.202.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
|
|
15
|
+
django_bulk_hooks-0.1.202.dist-info/METADATA,sha256=sJY6iID8owgHJErIN8ZUhXNjJ7Znl1F8HedZiroE8_0,7418
|
|
16
|
+
django_bulk_hooks-0.1.202.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
17
|
+
django_bulk_hooks-0.1.202.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|