summaryrefslogtreecommitdiff
path: root/tests/distinct_on_fields
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-03-10 09:16:28 +0100
committerGitHub <noreply@github.com>2021-03-10 09:16:28 +0100
commitba9a2b754452b542d3f472f0acce6f940911aced (patch)
tree3ef805503af0ff58dedba310ae18a0b1f14c8edd /tests/distinct_on_fields
parent6f5dbe9dbe45b23b3befe4f1cd2ea13b6049ab96 (diff)
downloaddjango-ba9a2b754452b542d3f472f0acce6f940911aced.tar.gz
Refs #32508 -- Raised TypeError instead of using "assert" on unsupported operations for sliced querysets.
Diffstat (limited to 'tests/distinct_on_fields')
-rw-r--r--tests/distinct_on_fields/tests.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/distinct_on_fields/tests.py b/tests/distinct_on_fields/tests.py
index 34d4509cec..f87a3affb3 100644
--- a/tests/distinct_on_fields/tests.py
+++ b/tests/distinct_on_fields/tests.py
@@ -98,6 +98,11 @@ class DistinctOnTests(TestCase):
c2 = c1.distinct('pk')
self.assertNotIn('OUTER JOIN', str(c2.query))
+ def test_sliced_queryset(self):
+ msg = 'Cannot create distinct fields once a slice has been taken.'
+ with self.assertRaisesMessage(TypeError, msg):
+ Staff.objects.all()[0:5].distinct('name')
+
def test_transform(self):
new_name = self.t1.name.upper()
self.assertNotEqual(self.t1.name, new_name)