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

@@ -82,17 +82,18 @@ def select_related(*related_fields):
82
82
  ids_to_fetch.append(obj.pk)
83
83
 
84
84
  # Always validate fields for nested field errors, regardless of whether we need to fetch
85
- for field in related_fields:
86
- if "." in field or "__" in field:
87
- raise ValueError(
88
- f"@select_related does not support nested fields like '{field}'"
89
- )
85
+ # Note: We allow nested fields as Django's select_related supports them
90
86
 
91
87
  fetched = {}
92
88
  if ids_to_fetch:
93
89
  # Validate fields before passing to select_related
94
90
  validated_fields = []
95
91
  for field in related_fields:
92
+ # For nested fields (containing __), let Django's select_related handle validation
93
+ if "__" in field:
94
+ validated_fields.append(field)
95
+ continue
96
+
96
97
  try:
97
98
  # Handle Mock objects that don't have _meta
98
99
  if hasattr(model_cls, "_meta"):
@@ -112,9 +113,13 @@ def select_related(*related_fields):
112
113
 
113
114
  if validated_fields:
114
115
  # Use the base manager to avoid recursion
115
- fetched = model_cls._base_manager.select_related(
116
- *validated_fields
117
- ).in_bulk(ids_to_fetch)
116
+ try:
117
+ fetched = model_cls._base_manager.select_related(
118
+ *validated_fields
119
+ ).in_bulk(ids_to_fetch)
120
+ except Exception:
121
+ # If select_related fails (e.g., invalid nested fields), skip preloading
122
+ fetched = {}
118
123
 
119
124
  for obj in new_records:
120
125
  preloaded = fetched.get(obj.pk)
@@ -126,8 +131,8 @@ def select_related(*related_fields):
126
131
  if field in obj._state.fields_cache:
127
132
  # don't override values that were explicitly set or already loaded
128
133
  continue
129
- if "." in field or "__" in field:
130
- # This should have been caught earlier, but just in case
134
+ if "." in field:
135
+ # Skip fields with dots (legacy format, not supported)
131
136
  continue
132
137
 
133
138
  try:
@@ -181,8 +186,8 @@ def bulk_hook(model_cls, event, when=None, priority=None):
181
186
  def __init__(self):
182
187
  self.func = func
183
188
 
184
- def handle(self, new_instances, original_instances):
185
- return self.func(new_instances, original_instances)
189
+ def handle(self, new_records=None, old_records=None, **kwargs):
190
+ return self.func(new_records, old_records)
186
191
 
187
192
  # Register the hook using the registry
188
193
  register_hook(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: django-bulk-hooks
3
- Version: 0.1.262
3
+ Version: 0.1.263
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
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
- Requires-Dist: Django (>=4.0)
15
+ Requires-Dist: django (>=5.2.0,<6.0.0)
16
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
@@ -2,7 +2,7 @@ django_bulk_hooks/__init__.py,sha256=hsbKduccFEcsV4KIw8CbxCUDOtLZwToCc-XP3sqNy-8
2
2
  django_bulk_hooks/conditions.py,sha256=V_f3Di2uCVUjoyfiU4BQCHmI4uUIRSRroApDcXlvnso,6349
3
3
  django_bulk_hooks/constants.py,sha256=3x1H1fSUUNo0DZONN7GUVDuySZctTR-jtByBHmAIX5w,303
4
4
  django_bulk_hooks/context.py,sha256=jlLsqGZbj__J0-iBUp1D6jTrlDEiX3qIo0XlywW4D9I,2244
5
- django_bulk_hooks/decorators.py,sha256=32ffydS9tARaG_WJoiVri7zJnfS2iMd7SuZ8L_sRAGM,7985
5
+ django_bulk_hooks/decorators.py,sha256=k70-BzWwS3wZu_uph5B5qXd6YpwXLQ9hMpOzPUy6iMI,8256
6
6
  django_bulk_hooks/engine.py,sha256=M3b7Rcb65PYAZTLfWrIRi99BUBPgSLCryL3MSjMVlfQ,2663
7
7
  django_bulk_hooks/enums.py,sha256=Zo8_tJzuzZ2IKfVc7gZ-0tWPT8q1QhqZbAyoh9ZVJbs,381
8
8
  django_bulk_hooks/handler.py,sha256=Bx-W6yyiciKMyy-BRxUt3CmRPCrX9_LhQgU-5LaJTjg,6019
@@ -11,7 +11,7 @@ django_bulk_hooks/models.py,sha256=WtSfc4GBOG_oOt8n37cVvid0MtFIGze9JYKSixil2y0,4
11
11
  django_bulk_hooks/priority.py,sha256=HG_2D35nga68lBCZmSXTcplXrjFoRgZFRDOy4ROKonY,376
12
12
  django_bulk_hooks/queryset.py,sha256=-Fuo6K4f4Mhwq9lUkAE4rpaVUHAvGASgktYJRjg-wXY,77120
13
13
  django_bulk_hooks/registry.py,sha256=GRUTGVQEO2sdkC9OaZ9Q3U7mM-3Ix83uTyvrlTtpatw,1317
14
- django_bulk_hooks-0.1.262.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
- django_bulk_hooks-0.1.262.dist-info/METADATA,sha256=dh0WsqOdiy_L8HTSwFduekbyeb-tmNHVo2QqzWv9ZkU,9061
16
- django_bulk_hooks-0.1.262.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
- django_bulk_hooks-0.1.262.dist-info/RECORD,,
14
+ django_bulk_hooks-0.1.263.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
+ django_bulk_hooks-0.1.263.dist-info/METADATA,sha256=XZX4cOne2oJcQ_hS1Tj1jvfXKSb6TNNQgvvBCW2VPNo,9070
16
+ django_bulk_hooks-0.1.263.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
+ django_bulk_hooks-0.1.263.dist-info/RECORD,,