Skip to content

Commit

Permalink
fix: 修改ignore_conflicts参数为on_conflict TencentBlueKing#1464
Browse files Browse the repository at this point in the history
  • Loading branch information
huangpixu committed Jan 20, 2025
1 parent 749d7e4 commit 72bdb1f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions itsm/ticket/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ def _batched_insert(self, objs, fields, batch_size, ignore_conflicts=False):
max_batch_size = max(ops.bulk_batch_size(fields, objs), 1)
batch_size = min(batch_size, max_batch_size) if batch_size else max_batch_size
inserted_rows = []
on_conflict = "DO NOTHING" if ignore_conflicts else None
bulk_return = connections[self.db].features.can_return_rows_from_bulk_insert
for item in [objs[i : i + batch_size] for i in range(0, len(objs), batch_size)]:
if bulk_return and not ignore_conflicts:
Expand All @@ -1012,15 +1013,15 @@ def _batched_insert(self, objs, fields, batch_size, ignore_conflicts=False):
fields=fields,
using=self.db,
returning_fields=self.model._meta.db_returning_fields,
ignore_conflicts=ignore_conflicts,
on_conflict=on_conflict,
)
)
else:
self._insert(
item,
fields=fields,
using=self.db,
ignore_conflicts=ignore_conflicts,
on_conflict=on_conflict,
)
return inserted_rows

Expand Down

0 comments on commit 72bdb1f

Please sign in to comment.