summaryrefslogtreecommitdiff
path: root/tests/queries
diff options
context:
space:
mode:
authormgaligniana <marcelogaligniana@gmail.com>2022-04-12 08:13:21 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-04-12 08:18:22 +0200
commitd2263b7b87a2af5dcd6964937b157b7e1cf2881f (patch)
tree7f5178f8e0085c01027974715607e57068dd446d /tests/queries
parent06ebaa9e287137d4496a2736b055f1c6aed95839 (diff)
downloaddjango-d2263b7b87a2af5dcd6964937b157b7e1cf2881f.tar.gz
Refs #18414 -- Added tests for selected columns of sliced distinct querysets.
Diffstat (limited to 'tests/queries')
-rw-r--r--tests/queries/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 7b70a5ae0a..395a298a9e 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_sliced_distinct_exists(self):
+ with CaptureQueriesContext(connection) as captured_queries:
+ self.assertIs(Article.objects.distinct()[1:3].exists(), False)
+ self.assertEqual(len(captured_queries), 1)
+ captured_sql = captured_queries[0]["sql"]
+ self.assertIn(connection.ops.quote_name("id"), captured_sql)
+ self.assertIn(connection.ops.quote_name("name"), captured_sql)
+
def test_ticket_18414(self):
Article.objects.create(name="one", created=datetime.datetime.now())
Article.objects.create(name="one", created=datetime.datetime.now())