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
1 changed files with 6 additions and 6 deletions

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):
"""