1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #34744 -- Prevented recreation of migration for constraints with a dict_keys.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
David Sanders
2023-07-27 17:07:48 +10:00
committed by Mariusz Felisiak
parent dd45d5223b
commit 76c3e310dd
3 changed files with 98 additions and 0 deletions

View File

@@ -200,6 +200,44 @@ class QTests(SimpleTestCase):
path, args, kwargs = q.deconstruct()
self.assertEqual(Q(*args, **kwargs), q)
def test_equal(self):
self.assertEqual(Q(), Q())
self.assertEqual(
Q(("pk__in", (1, 2))),
Q(("pk__in", [1, 2])),
)
self.assertEqual(
Q(("pk__in", (1, 2))),
Q(pk__in=[1, 2]),
)
self.assertEqual(
Q(("pk__in", (1, 2))),
Q(("pk__in", {1: "first", 2: "second"}.keys())),
)
self.assertNotEqual(
Q(name__iexact=F("other_name")),
Q(name=Lower(F("other_name"))),
)
def test_hash(self):
self.assertEqual(hash(Q()), hash(Q()))
self.assertEqual(
hash(Q(("pk__in", (1, 2)))),
hash(Q(("pk__in", [1, 2]))),
)
self.assertEqual(
hash(Q(("pk__in", (1, 2)))),
hash(Q(pk__in=[1, 2])),
)
self.assertEqual(
hash(Q(("pk__in", (1, 2)))),
hash(Q(("pk__in", {1: "first", 2: "second"}.keys()))),
)
self.assertNotEqual(
hash(Q(name__iexact=F("other_name"))),
hash(Q(name=Lower(F("other_name")))),
)
def test_flatten(self):
q = Q()
self.assertEqual(list(q.flatten()), [q])