#32657 closed Bug (fixed)
Combining an empty Q with a negated Exists un-negates the Exists lookup
Reported by: | Jaap Roes | Owned by: | Simon Charette |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.2 |
Severity: | Normal | Keywords: | |
Cc: | Simon Charette | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The following test case fails in Django 3.2 and main:
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.
Change History (6)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
Cc: | added |
---|---|
Component: | Uncategorized → Database layer (models, ORM) |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:4 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
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