diff options
author | mgaligniana <marcelogaligniana@gmail.com> | 2022-04-11 09:25:26 -0300 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-04-12 08:18:22 +0200 |
commit | 0ad5316f22eabe8fa8b22dc92e61170cfacc3c78 (patch) | |
tree | 93fb5aeda702eee5be994d73bc8324fb7f2a9520 /tests/queries | |
parent | d2263b7b87a2af5dcd6964937b157b7e1cf2881f (diff) | |
download | django-0ad5316f22eabe8fa8b22dc92e61170cfacc3c78.tar.gz |
Fixed #24296 -- Made QuerySet.exists() clear selected columns for not sliced distinct querysets.
Diffstat (limited to 'tests/queries')
-rw-r--r-- | tests/queries/tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 395a298a9e..77f0eb655c 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -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) |