mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #27149 -- Fixed sql.Query identity.
By making Query subclass BaseExpression in
3543129822 the former defined it's
identity based off _construct_args which is not appropriate.
This commit is contained in:
committed by
Mariusz Felisiak
parent
556fa4bbba
commit
bbf141bcdc
@@ -150,3 +150,31 @@ class TestQuery(SimpleTestCase):
|
||||
msg = 'Cannot filter against a non-conditional expression.'
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
query.build_where(Func(output_field=CharField()))
|
||||
|
||||
def test_equality(self):
|
||||
self.assertNotEqual(
|
||||
Author.objects.all().query,
|
||||
Author.objects.filter(item__name='foo').query,
|
||||
)
|
||||
self.assertEqual(
|
||||
Author.objects.filter(item__name='foo').query,
|
||||
Author.objects.filter(item__name='foo').query,
|
||||
)
|
||||
self.assertEqual(
|
||||
Author.objects.filter(item__name='foo').query,
|
||||
Author.objects.filter(Q(item__name='foo')).query,
|
||||
)
|
||||
|
||||
def test_hash(self):
|
||||
self.assertNotEqual(
|
||||
hash(Author.objects.all().query),
|
||||
hash(Author.objects.filter(item__name='foo').query)
|
||||
)
|
||||
self.assertEqual(
|
||||
hash(Author.objects.filter(item__name='foo').query),
|
||||
hash(Author.objects.filter(item__name='foo').query),
|
||||
)
|
||||
self.assertEqual(
|
||||
hash(Author.objects.filter(item__name='foo').query),
|
||||
hash(Author.objects.filter(Q(item__name='foo')).query),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user