diff options
author | arsalan.ghassemi <arsalan.ghassemi-ext@johnpaul.com> | 2021-11-23 18:22:52 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-11-23 20:43:20 +0100 |
commit | bdcda1ca9ba254743269e482384c2711ac34b1f1 (patch) | |
tree | 068cbf6d324e61c83539f51dfc44796e36bb392c /tests/distinct_on_fields | |
parent | aec71aaa5b029640ce066fe5dc34f7a0050d50b2 (diff) | |
download | django-bdcda1ca9ba254743269e482384c2711ac34b1f1.tar.gz |
Fixed #33309 -- Fixed QuerySet.distinct() crash on mixed case annotation.
Diffstat (limited to 'tests/distinct_on_fields')
-rw-r--r-- | tests/distinct_on_fields/tests.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/distinct_on_fields/tests.py b/tests/distinct_on_fields/tests.py index 5404c3eb41..a34c67016f 100644 --- a/tests/distinct_on_fields/tests.py +++ b/tests/distinct_on_fields/tests.py @@ -1,5 +1,5 @@ from django.db import connection -from django.db.models import CharField, Max +from django.db.models import CharField, F, Max from django.db.models.functions import Lower from django.test import TestCase, skipUnlessDBFeature from django.test.utils import register_lookup @@ -149,3 +149,9 @@ class DistinctOnTests(TestCase): """ staff = Staff.objects.distinct('name').order_by('name', '-organisation').get(name='p1') self.assertEqual(staff.organisation, 'o2') + + def test_distinct_on_mixed_case_annotation(self): + qs = Staff.objects.annotate( + nAmEAlIaS=F('name'), + ).distinct('nAmEAlIaS').order_by('nAmEAlIaS') + self.assertSequenceEqual(qs, [self.p1_o1, self.p2_o1, self.p3_o1]) |