mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +00:00
Subquery deconstruction support required implementing complex and
expensive equality rules for sql.Query objects for little benefit as
the latter cannot themselves be made deconstructible to their reference
to model classes.
Making Expression @deconstructible and not BaseExpression allows
interested parties to conform to the "expression" API even if they are
not deconstructible as it's only a requirement for expressions allowed
in Model fields and meta options (e.g. constraints, indexes).
Thanks Phillip Cutter for the report.
This also fixes a performance regression in bbf141bcdc.
This commit is contained in:
parent
4f600673d7
commit
c8b6594305
6 changed files with 31 additions and 65 deletions
|
|
@ -150,31 +150,3 @@ 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),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue