mirror of
https://github.com/django/django.git
synced 2025-10-30 00:56:09 +00:00
Fixed #19102 -- Fixed fast-path delete for modified SELECT clause cases
There was a bug introduced in #18676 which caused fast-path deletes implemented as "DELETE WHERE pk IN <subquery>" to fail if the SELECT clause contained additional stuff (for example extra() and annotate()). Thanks to Trac alias pressureman for spotting this regression.
This commit is contained in:
@@ -431,13 +431,9 @@ class Query(object):
|
||||
|
||||
def has_results(self, using):
|
||||
q = self.clone()
|
||||
q.clear_select_clause()
|
||||
q.add_extra({'a': 1}, None, None, None, None, None)
|
||||
q.select = []
|
||||
q.select_fields = []
|
||||
q.default_cols = False
|
||||
q.select_related = False
|
||||
q.set_extra_mask(('a',))
|
||||
q.set_aggregate_mask(())
|
||||
q.set_extra_mask(['a'])
|
||||
q.clear_ordering(True)
|
||||
q.set_limits(high=1)
|
||||
compiler = q.get_compiler(using=using)
|
||||
@@ -1626,6 +1622,17 @@ class Query(object):
|
||||
"""
|
||||
return not self.low_mark and self.high_mark is None
|
||||
|
||||
def clear_select_clause(self):
|
||||
"""
|
||||
Removes all fields from SELECT clause.
|
||||
"""
|
||||
self.select = []
|
||||
self.select_fields = []
|
||||
self.default_cols = False
|
||||
self.select_related = False
|
||||
self.set_extra_mask(())
|
||||
self.set_aggregate_mask(())
|
||||
|
||||
def clear_select_fields(self):
|
||||
"""
|
||||
Clears the list of fields to select (but not extra_select columns).
|
||||
|
||||
Reference in New Issue
Block a user