mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #24296 -- Made QuerySet.exists() clear selected columns for not sliced distinct querysets.
This commit is contained in:
committed by
Mariusz Felisiak
parent
d2263b7b87
commit
0ad5316f22
@@ -2226,6 +2226,14 @@ class ExistsSql(TestCase):
|
||||
self.assertNotIn(id, qstr)
|
||||
self.assertNotIn(name, qstr)
|
||||
|
||||
def test_distinct_exists(self):
|
||||
with CaptureQueriesContext(connection) as captured_queries:
|
||||
self.assertIs(Article.objects.distinct().exists(), False)
|
||||
self.assertEqual(len(captured_queries), 1)
|
||||
captured_sql = captured_queries[0]["sql"]
|
||||
self.assertNotIn(connection.ops.quote_name("id"), captured_sql)
|
||||
self.assertNotIn(connection.ops.quote_name("name"), captured_sql)
|
||||
|
||||
def test_sliced_distinct_exists(self):
|
||||
with CaptureQueriesContext(connection) as captured_queries:
|
||||
self.assertIs(Article.objects.distinct()[1:3].exists(), False)
|
||||
|
||||
Reference in New Issue
Block a user