@@ -244,7 +244,6 @@ def execute_sql(self, result_type):
244
244
return self .update (values )
245
245
246
246
def update (self , values ):
247
- multi = True
248
247
spec = {}
249
248
for field , value in values :
250
249
if field .primary_key :
@@ -253,23 +252,18 @@ def update(self, values):
253
252
raise NotSupportedError ("QuerySet.update() with expression not supported." )
254
253
# .update(foo=123) --> {'$set': {'foo': 123}}
255
254
spec .setdefault ("$set" , {})[field .column ] = value
256
-
257
- if field .unique :
258
- multi = False
259
-
260
- return self .execute_update (spec , multi )
255
+ return self .execute_update (spec )
261
256
262
257
@wrap_database_errors
263
- def execute_update (self , update_spec , multi = True , ** kwargs ):
258
+ def execute_update (self , update_spec , ** kwargs ):
264
259
collection = self .get_collection ()
265
260
try :
266
261
criteria = self .build_query ().mongo_query
267
262
except EmptyResultSet :
268
263
return 0
269
264
options = self .connection .operation_flags .get ("update" , {})
270
265
options = dict (options , ** kwargs )
271
- method = "update_many" if multi else "update_one"
272
- return getattr (collection , method )(criteria , update_spec , ** options ).matched_count
266
+ return collection .update_many (criteria , update_spec , ** options ).matched_count
273
267
274
268
275
269
class SQLAggregateCompiler (SQLCompiler ):
0 commit comments