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 @@ -324,8 +324,14 @@ def check_query(self):
324
324
)
325
325
326
326
327
- class SQLUpdateCompiler (SQLCompiler ):
327
+ class SQLUpdateCompiler (compiler . SQLUpdateCompiler , SQLCompiler ):
328
328
def execute_sql (self , result_type ):
329
+ """
330
+ Execute the specified update. Return the number of rows affected by
331
+ the primary update query. The "primary update query" is the first
332
+ non-empty query that is executed. Row counts for any subsequent,
333
+ related queries are not available.
334
+ """
329
335
self .pre_sql_setup ()
330
336
values = []
331
337
for field , _ , value in self .query .values :
@@ -340,7 +346,14 @@ def execute_sql(self, result_type):
340
346
)
341
347
prepared = field .get_db_prep_save (value , connection = self .connection )
342
348
values .append ((field , prepared ))
343
- return self .update (values )
349
+ is_empty = not bool (values )
350
+ rows = 0 if is_empty else self .update (values )
351
+ for query in self .query .get_related_updates ():
352
+ aux_rows = query .get_compiler (self .using ).execute_sql (result_type )
353
+ if is_empty and aux_rows :
354
+ rows = aux_rows
355
+ is_empty = False
356
+ return rows
344
357
345
358
def update (self , values ):
346
359
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