Skip to content

Commit 39e15fd

Browse files
committed
wraps database error in update_many.
1 parent 12cebdb commit 39e15fd

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
@@ -611,18 +611,18 @@ def execute_sql(self, result_type):
611611
except EmptyResultSet:
612612
return 0
613613
is_empty = not bool(values)
614-
rows = (
615-
0
616-
if is_empty
617-
else self.collection.update_many(criteria, [{"$set": values}]).matched_count
618-
)
614+
rows = 0 if is_empty else self.update(criteria, [{"$set": values}])
619615
for query in self.query.get_related_updates():
620616
aux_rows = query.get_compiler(self.using).execute_sql(result_type)
621617
if is_empty and aux_rows:
622618
rows = aux_rows
623619
is_empty = False
624620
return rows
625621

622+
@wrap_database_errors
623+
def update(self, criteria, pipeline):
624+
return self.collection.update_many(criteria, pipeline).matched_count
625+
626626
def get_where(self):
627627
return self.query.where
628628

0 commit comments

Comments
 (0)