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

@@ -555,8 +555,28 @@ class HookQuerySet(models.QuerySet):
555
555
  if not model_fields:
556
556
  continue
557
557
 
558
- # Use Django's update() with CASE statements for bulk update
559
- pks = [obj.pk for obj in objs]
558
+ # For MTI, we need to handle parent links correctly
559
+ # The root model (first in chain) has its own PK
560
+ # Child models use the parent link to reference the root PK
561
+ if model == inheritance_chain[0]:
562
+ # Root model - use primary keys directly
563
+ pks = [obj.pk for obj in objs]
564
+ filter_field = 'pk'
565
+ else:
566
+ # Child model - use parent link field
567
+ parent_link = None
568
+ for parent_model in inheritance_chain:
569
+ if parent_model in model._meta.parents:
570
+ parent_link = model._meta.parents[parent_model]
571
+ break
572
+
573
+ if parent_link is None:
574
+ # This shouldn't happen in proper MTI, but handle gracefully
575
+ continue
576
+
577
+ # Get the parent link values (these should be the same as the root PKs)
578
+ pks = [getattr(obj, parent_link.attname) for obj in objs]
579
+ filter_field = parent_link.attname
560
580
 
561
581
  if pks:
562
582
  base_qs = model._base_manager.using(self.db)
@@ -569,12 +589,12 @@ class HookQuerySet(models.QuerySet):
569
589
 
570
590
  for pk, obj in zip(pks, objs):
571
591
  value = getattr(obj, field_name)
572
- when_statements.append(When(pk=pk, then=Value(value, output_field=field)))
592
+ when_statements.append(When(**{filter_field: pk}, then=Value(value, output_field=field)))
573
593
 
574
594
  case_statements[field_name] = Case(*when_statements, output_field=field)
575
595
 
576
- # Execute the update
577
- updated_count = base_qs.filter(pk__in=pks).update(**case_statements)
596
+ # Execute the update using the appropriate filter field
597
+ updated_count = base_qs.filter(**{f"{filter_field}__in": pks}).update(**case_statements)
578
598
  total_updated += updated_count
579
599
 
580
600
  return total_updated
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: django-bulk-hooks
3
- Version: 0.1.183
3
+ Version: 0.1.184
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=KLEjpQRt4WlzgBAf_X3XOAPUQM8Jmc1fIt8yr62FPQc,3044
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=9AdCzpnnFv392YR76uNVNiGMuvdtEp6xK1wNkOPJcj4,24536
12
+ django_bulk_hooks/queryset.py,sha256=gQvwa506wYi206B13I-lwkZi5Ua9nWcKctwCCgLGuaQ,25614
13
13
  django_bulk_hooks/registry.py,sha256=-mQBizJ06nz_tajZBinViKx_uP2Tbc1tIpTEMv7lwKA,705
14
- django_bulk_hooks-0.1.183.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
- django_bulk_hooks-0.1.183.dist-info/METADATA,sha256=uVJYanMqkRcvAFD4FX7oXU1Gm08tLIp3u5g1O0mh2lg,6951
16
- django_bulk_hooks-0.1.183.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
- django_bulk_hooks-0.1.183.dist-info/RECORD,,
14
+ django_bulk_hooks-0.1.184.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
+ django_bulk_hooks-0.1.184.dist-info/METADATA,sha256=zj7hawgW0Z19ZUhnTcTMcx-pMXy_PvepfzUdstynZjU,6951
16
+ django_bulk_hooks-0.1.184.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
+ django_bulk_hooks-0.1.184.dist-info/RECORD,,