django-bulk-hooks 0.1.269__tar.gz → 0.1.271__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.269 → django_bulk_hooks-0.1.271}/PKG-INFO +1 -1
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/queryset.py +16 -6
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/pyproject.toml +1 -1
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/LICENSE +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/README.md +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/__init__.py +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/conditions.py +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/constants.py +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/context.py +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/decorators.py +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/engine.py +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/enums.py +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/handler.py +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/manager.py +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/models.py +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/priority.py +0 -0
- {django_bulk_hooks-0.1.269 → django_bulk_hooks-0.1.271}/django_bulk_hooks/registry.py +0 -0
|
@@ -532,31 +532,41 @@ class HookQuerySetMixin:
|
|
|
532
532
|
unique_values = []
|
|
533
533
|
for obj in objs:
|
|
534
534
|
unique_value = {}
|
|
535
|
+
query_fields = {} # Track which database field to use for each unique field
|
|
535
536
|
for field_name in unique_fields:
|
|
536
537
|
if hasattr(obj, field_name):
|
|
537
538
|
unique_value[field_name] = getattr(obj, field_name)
|
|
539
|
+
query_fields[field_name] = field_name
|
|
538
540
|
elif hasattr(obj, field_name + '_id'):
|
|
539
541
|
# Handle ForeignKey fields where _id suffix is used
|
|
540
542
|
unique_value[field_name] = getattr(obj, field_name + '_id')
|
|
543
|
+
query_fields[field_name] = field_name + '_id' # Use _id field for query
|
|
541
544
|
if unique_value:
|
|
542
|
-
unique_values.append(unique_value)
|
|
545
|
+
unique_values.append((unique_value, query_fields))
|
|
543
546
|
|
|
544
547
|
if unique_values:
|
|
545
548
|
# Query the database to see which records already exist - SINGLE BULK QUERY
|
|
546
549
|
from django.db.models import Q
|
|
547
550
|
|
|
548
551
|
existing_filters = Q()
|
|
549
|
-
for unique_value in unique_values:
|
|
552
|
+
for unique_value, query_fields in unique_values:
|
|
550
553
|
filter_kwargs = {}
|
|
551
554
|
for field_name, value in unique_value.items():
|
|
552
|
-
|
|
555
|
+
# Use the correct database field name (may include _id suffix)
|
|
556
|
+
db_field_name = query_fields[field_name]
|
|
557
|
+
filter_kwargs[db_field_name] = value
|
|
553
558
|
existing_filters |= Q(**filter_kwargs)
|
|
554
559
|
|
|
560
|
+
logger.debug(f"DEBUG: Existence check query filters: {existing_filters}")
|
|
561
|
+
logger.debug(f"DEBUG: Unique fields for values_list: {unique_fields}")
|
|
562
|
+
|
|
555
563
|
# Get all existing records in one query and create a lookup set
|
|
564
|
+
# We need to use the original unique_fields for values_list to maintain consistency
|
|
556
565
|
existing_records_lookup = set()
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
566
|
+
existing_query = model_cls.objects.filter(existing_filters)
|
|
567
|
+
logger.debug(f"DEBUG: Existence check SQL: {existing_query.query}")
|
|
568
|
+
|
|
569
|
+
for existing_record in existing_query.values_list(*unique_fields):
|
|
560
570
|
# Convert tuple to a hashable key for lookup
|
|
561
571
|
existing_records_lookup.add(existing_record)
|
|
562
572
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "django-bulk-hooks"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.271"
|
|
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
|
|
File without changes
|