Skip to content

Commit 21a0d9e

Browse files
committed
fix(django): added return in safe_bulk_create and update
1 parent c013249 commit 21a0d9e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

python_utils/django_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
from django.forms import model_to_dict
1616
from django.utils import timezone
1717

18-
from python_utils.imports import import_optional_dependency
1918
from python_utils.db import fetch_all
19+
from python_utils.imports import import_optional_dependency
2020

2121
Model_T = TypeVar('Model_T', bound=Model)
2222

23+
logger = logging.getLogger(__name__)
24+
2325

2426
class ExtendedEncoder(DjangoJSONEncoder): # pragma no cover
2527
"""Custom JSON Encoder that processes fields like date etc."""
@@ -441,7 +443,7 @@ def safe_bulk_create(
441443
except AttributeError:
442444
continue
443445

444-
model.objects.bulk_create(records, batch_size=batch_size)
446+
return model.objects.bulk_create(records, batch_size=batch_size)
445447

446448

447449
def safe_bulk_update(
@@ -482,10 +484,8 @@ def safe_bulk_update(
482484
timestamp = timezone.now()
483485
for record in records:
484486
setattr(record, updated_at_field, timestamp)
485-
model.objects.bulk_update(records, fields, batch_size=batch_size)
486-
487487

488-
logger = logging.getLogger(__name__)
488+
return model.objects.bulk_update(records, fields, batch_size=batch_size)
489489

490490

491491
def call_procedure(procedure_name: str, params: List[Any] = None):

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = cardo-python-utils
3-
version = 0.1.2
3+
version = 0.1.3
44
description = Python library enhanced with a wide range of functions for different scenarios.
55
long_description = file: README.rst
66
url = https://github.com/CardoAI/cardo-python-utils

0 commit comments

Comments
 (0)