django-bulk-hooks 0.1.89__tar.gz → 0.1.90__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: django-bulk-hooks
3
- Version: 0.1.89
3
+ Version: 0.1.90
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
@@ -209,8 +209,13 @@ class IsEqual(HookCondition):
209
209
  self.value = value
210
210
 
211
211
  def check(self, instance, original_instance=None):
212
- current_value = resolve_dotted_attr(instance, self.field)
213
- return current_value == self.value
212
+ # Handle the case where the field might not exist yet
213
+ try:
214
+ current_value = getattr(instance, self.field, None)
215
+ return current_value == self.value
216
+ except Exception:
217
+ # If there's any error accessing the field, treat it as None
218
+ return self.value is None
214
219
 
215
220
  def get_required_fields(self):
216
221
  return {self.field.split('.')[0]}
@@ -57,14 +57,26 @@ def run(model_cls, event, new_instances, original_instances=None, ctx=None):
57
57
  to_process_new = []
58
58
  to_process_old = []
59
59
 
60
+ logger.debug(f"Checking condition {condition.__class__.__name__} for {len(new_instances)} instances")
60
61
  for new, original in zip(new_instances, original_instances, strict=True):
61
- if condition.check(new, original):
62
- to_process_new.append(new)
63
- to_process_old.append(original)
62
+ logger.debug(f"Checking instance {new.__class__.__name__}(pk={new.pk})")
63
+ try:
64
+ matches = condition.check(new, original)
65
+ logger.debug(f"Condition check result: {matches}")
66
+ if matches:
67
+ to_process_new.append(new)
68
+ to_process_old.append(original)
69
+ except Exception as e:
70
+ logger.error(f"Error checking condition: {e}")
71
+ raise
64
72
 
65
73
  # Only call if we have matching instances
66
74
  if to_process_new:
75
+ logger.debug(f"Running hook for {len(to_process_new)} matching instances")
67
76
  func(new_records=to_process_new, old_records=to_process_old if any(to_process_old) else None)
77
+ else:
78
+ logger.debug("No instances matched condition")
68
79
  else:
69
80
  # No condition, process all instances
81
+ logger.debug("No condition, processing all instances")
70
82
  func(new_records=new_instances, old_records=original_instances if any(original_instances) else None)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "django-bulk-hooks"
3
- version = "0.1.89"
3
+ version = "0.1.90"
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"