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

@@ -58,12 +58,12 @@ class BulkHookManager(models.Manager):
58
58
  """
59
59
  import inspect
60
60
 
61
- qs = self.get_queryset()
61
+ queryset = self.get_queryset()
62
62
 
63
63
  # Check if this is our HookQuerySet or a different QuerySet
64
64
  if (
65
- hasattr(qs, "bulk_create")
66
- and "bypass_hooks" in inspect.signature(qs.bulk_create).parameters
65
+ hasattr(queryset, "bulk_create")
66
+ and "bypass_hooks" in inspect.signature(queryset.bulk_create).parameters
67
67
  ):
68
68
  # Our HookQuerySet - pass all parameters
69
69
  kwargs = {
@@ -73,13 +73,15 @@ class BulkHookManager(models.Manager):
73
73
  "update_fields": update_fields,
74
74
  "unique_fields": unique_fields,
75
75
  }
76
- return qs.bulk_create(
76
+ return queryset.bulk_create(
77
77
  objs,
78
78
  bypass_hooks=bypass_hooks,
79
79
  bypass_validation=bypass_validation,
80
80
  **kwargs,
81
81
  )
82
82
  else:
83
+ print("Different QuerySet")
84
+
83
85
  # Different QuerySet - only pass standard parameters
84
86
  kwargs = {
85
87
  "batch_size": batch_size,
@@ -88,7 +90,7 @@ class BulkHookManager(models.Manager):
88
90
  "update_fields": update_fields,
89
91
  "unique_fields": unique_fields,
90
92
  }
91
- return qs.bulk_create(objs, **kwargs)
93
+ return queryset.bulk_create(objs, **kwargs)
92
94
 
93
95
  def bulk_delete(
94
96
  self, objs, batch_size=None, bypass_hooks=False, bypass_validation=False
@@ -109,6 +109,14 @@ class HookQuerySet(models.QuerySet):
109
109
  # trickier so it's not done yet.
110
110
  if batch_size is not None and batch_size <= 0:
111
111
  raise ValueError("Batch size must be a positive integer.")
112
+
113
+ if not objs:
114
+ return objs
115
+
116
+ if any(not isinstance(obj, model_cls) for obj in objs):
117
+ raise TypeError(
118
+ f"bulk_create expected instances of {model_cls.__name__}, but got {set(type(obj).__name__ for obj in objs)}"
119
+ )
112
120
 
113
121
  # Check for MTI - if we detect multi-table inheritance, we need special handling
114
122
  # This follows Django's approach: check that the parents share the same concrete model
@@ -121,14 +129,6 @@ class HookQuerySet(models.QuerySet):
121
129
  is_mti = True
122
130
  break
123
131
 
124
- if not objs:
125
- return objs
126
-
127
- if any(not isinstance(obj, model_cls) for obj in objs):
128
- raise TypeError(
129
- f"bulk_create expected instances of {model_cls.__name__}, but got {set(type(obj).__name__ for obj in objs)}"
130
- )
131
-
132
132
  # Fire hooks before DB ops
133
133
  if not bypass_hooks:
134
134
  ctx = HookContext(model_cls)
@@ -150,22 +150,14 @@ class HookQuerySet(models.QuerySet):
150
150
  # Remove custom hook kwargs if present in self.bulk_create signature
151
151
  result = self._mti_bulk_create(
152
152
  objs,
153
- **{
154
- k: v
155
- for k, v in mti_kwargs.items()
156
- if k not in ["bypass_hooks", "bypass_validation"]
157
- },
153
+ mti_kwargs,
158
154
  )
159
155
  else:
160
156
  # For single-table models, use Django's built-in bulk_create
161
157
  # but we need to call it on the base manager to avoid recursion
162
158
  # Filter out custom parameters that Django's bulk_create doesn't accept
163
159
 
164
- # Use Django's original QuerySet to avoid recursive calls
165
- from django.db.models import QuerySet
166
-
167
- original_qs = QuerySet(model_cls, using=self.db)
168
- result = original_qs.bulk_create(
160
+ result = super().bulk_create(
169
161
  objs,
170
162
  batch_size=batch_size,
171
163
  ignore_conflicts=ignore_conflicts,
@@ -226,17 +218,12 @@ class HookQuerySet(models.QuerySet):
226
218
  fields_set.update(modified_fields)
227
219
  fields = list(fields_set)
228
220
 
229
- for i in range(0, len(objs), self.CHUNK_SIZE):
230
- chunk = objs[i : i + self.CHUNK_SIZE]
231
-
232
- # Call the base implementation to avoid re-triggering this method
233
- # Filter out custom parameters that Django's bulk_update doesn't accept
234
- django_kwargs = {
235
- k: v
236
- for k, v in kwargs.items()
237
- if k not in ["bypass_hooks", "bypass_validation"]
238
- }
239
- super().bulk_update(chunk, fields, **django_kwargs)
221
+ django_kwargs = {
222
+ k: v
223
+ for k, v in kwargs.items()
224
+ if k not in ["bypass_hooks", "bypass_validation"]
225
+ }
226
+ super().bulk_update(objs, fields, **django_kwargs)
240
227
 
241
228
  if not bypass_hooks:
242
229
  engine.run(model_cls, AFTER_UPDATE, objs, originals, ctx=ctx)
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: django-bulk-hooks
3
- Version: 0.1.175
3
+ Version: 0.1.176
4
4
  Summary: Hook-style hooks for Django bulk operations like bulk_create and bulk_update.
5
- Home-page: https://github.com/AugendLimited/django-bulk-hooks
6
5
  License: MIT
7
6
  Keywords: django,bulk,hooks
8
7
  Author: Konrad Beck
@@ -14,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.11
14
13
  Classifier: Programming Language :: Python :: 3.12
15
14
  Classifier: Programming Language :: Python :: 3.13
16
15
  Requires-Dist: Django (>=4.0)
16
+ Project-URL: Homepage, https://github.com/AugendLimited/django-bulk-hooks
17
17
  Project-URL: Repository, https://github.com/AugendLimited/django-bulk-hooks
18
18
  Description-Content-Type: text/markdown
19
19
 
@@ -6,12 +6,12 @@ django_bulk_hooks/decorators.py,sha256=WD7Jn7QAvY8F4wOsYlIpjoM9-FdHXSKB7hH9ot-lk
6
6
  django_bulk_hooks/engine.py,sha256=nA5PU9msk_Ju5Gf_sTd7GqPscuTxEW5itCDAoSScYGI,1645
7
7
  django_bulk_hooks/enums.py,sha256=Zo8_tJzuzZ2IKfVc7gZ-0tWPT8q1QhqZbAyoh9ZVJbs,381
8
8
  django_bulk_hooks/handler.py,sha256=xZt8iNdYF-ACz-MnKMY0co6scWINU5V5wC1lyDn844k,4854
9
- django_bulk_hooks/manager.py,sha256=OSzW8eVzknLV1WCvZcBkWMz9x_Vjq4bJM8raVXKiZvI,5085
9
+ django_bulk_hooks/manager.py,sha256=y0z-tnIZx60DlYPRyVdVbaR6IXeJzCQLE0m8IB6Igjw,5158
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=wP1PHzDJ-n_F6RtPzQUdB2j16aALabDl0gbaMJAE2eI,22812
12
+ django_bulk_hooks/queryset.py,sha256=Ii-5nXKUhN070LRWTjJNUjynWdtKDzRW7MuT3c6KQAw,22179
13
13
  django_bulk_hooks/registry.py,sha256=-mQBizJ06nz_tajZBinViKx_uP2Tbc1tIpTEMv7lwKA,705
14
- django_bulk_hooks-0.1.175.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
- django_bulk_hooks-0.1.175.dist-info/METADATA,sha256=HmgU2xtMNjhwLejwg5ehchMkJPSYn6B_JRcRmn3EoXs,6939
16
- django_bulk_hooks-0.1.175.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
17
- django_bulk_hooks-0.1.175.dist-info/RECORD,,
14
+ django_bulk_hooks-0.1.176.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
+ django_bulk_hooks-0.1.176.dist-info/METADATA,sha256=4t1fn4kW8CbHXjWVQcUbU_pAQ3SyT-MwCrsh5b0-19o,6951
16
+ django_bulk_hooks-0.1.176.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
+ django_bulk_hooks-0.1.176.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: poetry-core 2.1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any