File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -323,8 +323,14 @@ def check_query(self):
323
323
)
324
324
325
325
326
- class SQLUpdateCompiler (SQLCompiler ):
326
+ class SQLUpdateCompiler (compiler . SQLUpdateCompiler , SQLCompiler ):
327
327
def execute_sql (self , result_type ):
328
+ """
329
+ Execute the specified update. Return the number of rows affected by
330
+ the primary update query. The "primary update query" is the first
331
+ non-empty query that is executed. Row counts for any subsequent,
332
+ related queries are not available.
333
+ """
328
334
self .pre_sql_setup ()
329
335
values = []
330
336
for field , _ , value in self .query .values :
@@ -339,7 +345,14 @@ def execute_sql(self, result_type):
339
345
)
340
346
prepared = field .get_db_prep_save (value , connection = self .connection )
341
347
values .append ((field , prepared ))
342
- return self .update (values )
348
+ is_empty = not bool (values )
349
+ rows = 0 if is_empty else self .update (values )
350
+ for query in self .query .get_related_updates ():
351
+ aux_rows = query .get_compiler (self .using ).execute_sql (result_type )
352
+ if is_empty and aux_rows :
353
+ rows = aux_rows
354
+ is_empty = False
355
+ return rows
343
356
344
357
def update (self , values ):
345
358
spec = {}
Original file line number Diff line number Diff line change @@ -51,9 +51,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
51
51
"update.tests.AdvancedTests.test_update_ordered_by_inline_m2m_annotation" ,
52
52
"update.tests.AdvancedTests.test_update_ordered_by_m2m_annotation" ,
53
53
"update.tests.AdvancedTests.test_update_ordered_by_m2m_annotation_desc" ,
54
- # pymongo: ValueError: update cannot be empty
55
- "update.tests.SimpleTest.test_empty_update_with_inheritance" ,
56
- "update.tests.SimpleTest.test_nonempty_update_with_inheritance" ,
57
54
# Pattern lookups that use regexMatch don't work on JSONField:
58
55
# Unsupported conversion from array to string in $convert
59
56
"model_fields.test_jsonfield.TestQuerying.test_icontains" ,
You can’t perform that action at this time.
0 commit comments