1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed non-deterministic order in SubqueryTests.test_slice_subquery_and_query.

Slice on unordered subquery may be non-deterministic in some databases.
This commit is contained in:
Mariusz Felisiak 2023-08-10 05:33:13 +02:00 committed by GitHub
parent 80a5667c50
commit e69a9920e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2373,18 +2373,18 @@ class SubqueryTests(TestCase):
"""
query = DumbCategory.objects.filter(
id__in=DumbCategory.objects.order_by("-id")[0:2]
)[0:2]
self.assertEqual({x.id for x in query}, {3, 4})
).order_by("id")[0:2]
self.assertSequenceEqual([x.id for x in query], [3, 4])
query = DumbCategory.objects.filter(
id__in=DumbCategory.objects.order_by("-id")[1:3]
)[1:3]
self.assertEqual({x.id for x in query}, {3})
).order_by("id")[1:3]
self.assertSequenceEqual([x.id for x in query], [3])
query = DumbCategory.objects.filter(
id__in=DumbCategory.objects.order_by("-id")[2:]
)[1:]
self.assertEqual({x.id for x in query}, {2})
).order_by("id")[1:]
self.assertSequenceEqual([x.id for x in query], [2])
def test_related_sliced_subquery(self):
"""