1
0
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:
mgaligniana
2022-04-11 09:25:26 -03:00
committed by Mariusz Felisiak
parent d2263b7b87
commit 0ad5316f22
2 changed files with 9 additions and 1 deletions

View File

@@ -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)