{{{
class TestEmptyQExistsCombination(TestCase):
def test_combine(self):
q = Q() & Exists(Book.objects.all())
self.assertFalse(q.negated) # passes
def test_combine_negated(self):
q = Q() & ~Exists(Book.objects.all())
self.assertTrue(q.negated) # fails
}}}
I noticed this issue trying to work around issue #32651/ #32548.
--
Ticket URL: <https://code.djangoproject.com/ticket/32657>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Jaap Roes):
Note, in Django 3.1 the code in the previous tests will raise a
`TypeError`, the following test case achieves the same and passes in
Django 3.1, main and (from what I understand) Django 3.2.1
{{{
class TestEmptyQExistsCombination(TestCase):
def test_combine(self):
q = Q() & Q(Exists(Book.objects.all()))
self.assertFalse(q.children[0].negated)
def test_combine_negated(self):
q = Q() & Q(~Exists(Book.objects.all()))
self.assertTrue(q.children[0].negated)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32657#comment:1>
* cc: Simon Charette (added)
* type: Uncategorized => Bug
* component: Uncategorized => Database layer (models, ORM)
* stage: Unreviewed => Accepted
Comment:
This can be fixed by #32632.
--
Ticket URL: <https://code.djangoproject.com/ticket/32657#comment:2>
* owner: nobody => Simon Charette
* status: new => assigned
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/14309 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/32657#comment:3>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32657#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"c8b659430556dca0b2fe27cf2ea0f8290dbafecd" c8b65943]:
{{{
#!CommitTicketReference repository=""
revision="c8b659430556dca0b2fe27cf2ea0f8290dbafecd"
Fixed #32632, Fixed #32657 -- Removed flawed support for Subquery
deconstruction.
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
bbf141bcdc31f1324048af9233583a523ac54c94.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32657#comment:5>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"d5add5d3a26f98e961dfbcad67bb04d936f2f332" d5add5d3]:
{{{
#!CommitTicketReference repository=""
revision="d5add5d3a26f98e961dfbcad67bb04d936f2f332"
[3.2.x] Fixed #32632, Fixed #32657 -- Removed flawed support for Subquery
deconstruction.
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
bbf141bcdc31f1324048af9233583a523ac54c94.
Backport of c8b659430556dca0b2fe27cf2ea0f8290dbafecd from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32657#comment:6>