django-bulk-hooks 0.1.152__py3-none-any.whl → 0.1.154__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.
- django_bulk_hooks/manager.py +13 -7
- django_bulk_hooks/queryset.py +9 -4
- {django_bulk_hooks-0.1.152.dist-info → django_bulk_hooks-0.1.154.dist-info}/METADATA +1 -1
- {django_bulk_hooks-0.1.152.dist-info → django_bulk_hooks-0.1.154.dist-info}/RECORD +6 -6
- {django_bulk_hooks-0.1.152.dist-info → django_bulk_hooks-0.1.154.dist-info}/LICENSE +0 -0
- {django_bulk_hooks-0.1.152.dist-info → django_bulk_hooks-0.1.154.dist-info}/WHEEL +0 -0
django_bulk_hooks/manager.py
CHANGED
|
@@ -33,15 +33,21 @@ class BulkHookManager(models.Manager):
|
|
|
33
33
|
Delegate to QuerySet's bulk_create implementation.
|
|
34
34
|
This follows Django's pattern where Manager methods call QuerySet methods.
|
|
35
35
|
"""
|
|
36
|
+
kwargs = {
|
|
37
|
+
'batch_size': batch_size,
|
|
38
|
+
'ignore_conflicts': ignore_conflicts,
|
|
39
|
+
'update_conflicts': update_conflicts,
|
|
40
|
+
'update_fields': update_fields,
|
|
41
|
+
'unique_fields': unique_fields,
|
|
42
|
+
}
|
|
43
|
+
# Only include custom args if explicitly set to True
|
|
44
|
+
if bypass_hooks:
|
|
45
|
+
kwargs['bypass_hooks'] = bypass_hooks
|
|
46
|
+
if bypass_validation:
|
|
47
|
+
kwargs['bypass_validation'] = bypass_validation
|
|
36
48
|
return self.get_queryset().bulk_create(
|
|
37
49
|
objs,
|
|
38
|
-
|
|
39
|
-
ignore_conflicts=ignore_conflicts,
|
|
40
|
-
update_conflicts=update_conflicts,
|
|
41
|
-
update_fields=update_fields,
|
|
42
|
-
unique_fields=unique_fields,
|
|
43
|
-
bypass_hooks=bypass_hooks,
|
|
44
|
-
bypass_validation=bypass_validation,
|
|
50
|
+
**kwargs
|
|
45
51
|
)
|
|
46
52
|
|
|
47
53
|
def bulk_delete(
|
django_bulk_hooks/queryset.py
CHANGED
|
@@ -128,9 +128,10 @@ class HookQuerySet(models.QuerySet):
|
|
|
128
128
|
'update_fields': update_fields,
|
|
129
129
|
'unique_fields': unique_fields,
|
|
130
130
|
}
|
|
131
|
+
# Remove custom hook kwargs if present in self.bulk_create signature
|
|
131
132
|
result = self._mti_bulk_create(
|
|
132
133
|
objs,
|
|
133
|
-
**mti_kwargs
|
|
134
|
+
**{k: v for k, v in mti_kwargs.items() if k not in ['bypass_hooks', 'bypass_validation']}
|
|
134
135
|
)
|
|
135
136
|
else:
|
|
136
137
|
# For single-table models, use Django's built-in bulk_create
|
|
@@ -197,7 +198,9 @@ class HookQuerySet(models.QuerySet):
|
|
|
197
198
|
chunk = objs[i : i + self.CHUNK_SIZE]
|
|
198
199
|
|
|
199
200
|
# Call the base implementation to avoid re-triggering this method
|
|
200
|
-
|
|
201
|
+
# Filter out custom parameters that Django's bulk_update doesn't accept
|
|
202
|
+
django_kwargs = {k: v for k, v in kwargs.items() if k not in ['bypass_hooks', 'bypass_validation']}
|
|
203
|
+
super().bulk_update(chunk, fields, **django_kwargs)
|
|
201
204
|
|
|
202
205
|
if not bypass_hooks:
|
|
203
206
|
engine.run(model_cls, AFTER_UPDATE, objs, originals, ctx=ctx)
|
|
@@ -302,6 +305,8 @@ class HookQuerySet(models.QuerySet):
|
|
|
302
305
|
then single bulk insert into childmost table.
|
|
303
306
|
Sets auto_now_add/auto_now fields for each model in the chain.
|
|
304
307
|
"""
|
|
308
|
+
# Remove custom hook kwargs before passing to Django internals
|
|
309
|
+
django_kwargs = {k: v for k, v in kwargs.items() if k not in ['bypass_hooks', 'bypass_validation']}
|
|
305
310
|
if inheritance_chain is None:
|
|
306
311
|
inheritance_chain = self._get_inheritance_chain()
|
|
307
312
|
|
|
@@ -311,13 +316,13 @@ class HookQuerySet(models.QuerySet):
|
|
|
311
316
|
"Inheritance chain too deep - possible infinite recursion detected"
|
|
312
317
|
)
|
|
313
318
|
|
|
314
|
-
batch_size =
|
|
319
|
+
batch_size = django_kwargs.get("batch_size") or len(objs)
|
|
315
320
|
created_objects = []
|
|
316
321
|
with transaction.atomic(using=self.db, savepoint=False):
|
|
317
322
|
for i in range(0, len(objs), batch_size):
|
|
318
323
|
batch = objs[i : i + batch_size]
|
|
319
324
|
batch_result = self._process_mti_batch(
|
|
320
|
-
batch, inheritance_chain, **
|
|
325
|
+
batch, inheritance_chain, **django_kwargs
|
|
321
326
|
)
|
|
322
327
|
created_objects.extend(batch_result)
|
|
323
328
|
return created_objects
|
|
@@ -6,12 +6,12 @@ django_bulk_hooks/decorators.py,sha256=tckDcxtOzKCbgvS9QydgeIAWTFDEl-ch3_Q--ruEG
|
|
|
6
6
|
django_bulk_hooks/engine.py,sha256=3HbgV12JRYIy9IlygHPxZiHnFXj7EwzLyTuJNQeVIoI,1402
|
|
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=
|
|
9
|
+
django_bulk_hooks/manager.py,sha256=qEKWYOJRTt9OY-Iu2Juzbps7X6pEIt_PsVShXYrv30o,3010
|
|
10
10
|
django_bulk_hooks/models.py,sha256=5PBjBoGlHwAE5b4yaZ5kDjt5UtHfQp6pDrwB2XPs2tk,3850
|
|
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=gs7Ge5AoyVc6mea-jebedUNfwmM75zIpu1s6bO5qC7U,22903
|
|
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.154.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
|
|
15
|
+
django_bulk_hooks-0.1.154.dist-info/METADATA,sha256=bc34HReJ-mJfV0NhzbFqyBg2J0OhfKb_fZaEJ_3yUgA,6951
|
|
16
|
+
django_bulk_hooks-0.1.154.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
17
|
+
django_bulk_hooks-0.1.154.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|