Skip to content

Commit

Permalink
Fix bulk create without objects
Browse files Browse the repository at this point in the history
  • Loading branch information
WestonChan committed Sep 19, 2022
1 parent 419f270 commit 7e9cb15
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions simple_history/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ def bulk_create_with_history(
obj_when_list.append(When(**attributes, then=i))
q = Q(**attributes)
cumulative_filter = (cumulative_filter | q) if cumulative_filter else q
existing_objs_ids = list(
model_manager.filter(cumulative_filter).values_list("pk", flat=True)
existing_objs_ids = (
list(model_manager.filter(cumulative_filter).values_list("pk", flat=True))
if cumulative_filter
else []
)
objs_with_id = model_manager.bulk_create(
objs, batch_size=batch_size, ignore_conflicts=ignore_conflicts
Expand Down

0 comments on commit 7e9cb15

Please sign in to comment.