django-bulk-hooks 0.1.175__tar.gz → 0.1.176__tar.gz
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-0.1.175 → django_bulk_hooks-0.1.176}/PKG-INFO +3 -3
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/manager.py +7 -5
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/queryset.py +16 -29
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/pyproject.toml +1 -1
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/LICENSE +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/README.md +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/__init__.py +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/conditions.py +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/constants.py +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/context.py +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/decorators.py +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/engine.py +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/enums.py +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/handler.py +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/models.py +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/priority.py +0 -0
- {django_bulk_hooks-0.1.175 → django_bulk_hooks-0.1.176}/django_bulk_hooks/registry.py +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: django-bulk-hooks
|
|
3
|
-
Version: 0.1.
|
|
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
|
|
|
@@ -58,12 +58,12 @@ class BulkHookManager(models.Manager):
|
|
|
58
58
|
"""
|
|
59
59
|
import inspect
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
queryset = self.get_queryset()
|
|
62
62
|
|
|
63
63
|
# Check if this is our HookQuerySet or a different QuerySet
|
|
64
64
|
if (
|
|
65
|
-
hasattr(
|
|
66
|
-
and "bypass_hooks" in inspect.signature(
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "django-bulk-hooks"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.176"
|
|
4
4
|
description = "Hook-style hooks for Django bulk operations like bulk_create and bulk_update."
|
|
5
5
|
authors = ["Konrad Beck <konrad.beck@merchantcapital.co.za>"]
|
|
6
6
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|