Skip to content

Commit a8ff458

Browse files
committed
wraps database error in update_many.
1 parent bfbe6f0 commit a8ff458

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

django_mongodb/compiler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,18 +608,18 @@ def execute_sql(self, result_type):
608608
except EmptyResultSet:
609609
return 0
610610
is_empty = not bool(values)
611-
rows = (
612-
0
613-
if is_empty
614-
else self.collection.update_many(criteria, [{"$set": values}]).matched_count
615-
)
611+
rows = 0 if is_empty else self.update(criteria, [{"$set": values}])
616612
for query in self.query.get_related_updates():
617613
aux_rows = query.get_compiler(self.using).execute_sql(result_type)
618614
if is_empty and aux_rows:
619615
rows = aux_rows
620616
is_empty = False
621617
return rows
622618

619+
@wrap_database_errors
620+
def update(self, criteria, pipeline):
621+
return self.collection.update_many(criteria, pipeline).matched_count
622+
623623
def get_where(self):
624624
return self.query.where
625625

0 commit comments

Comments
 (0)