Opened 4 years ago
Closed 4 years ago
#31830 closed Bug (wontfix)
wrong result of QuerySet count() caused by incorrect handling of EmptyResultSet inside Exists() inside OR
Reported by: | zt_initech | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 2.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
When a queryset count() is called while the queryset has not been evaluated, if the filter has OR and one of the nodes in the OR is Exists and inside the Exists a EmptyResultSet is raised, the other nodes of the OR are not evaluated, the count just decides the EmptyResultSet applies to the outer queryset and returns count == 0.
This is the testcase: https://github.com/zt-initech/django/blob/ticket_31830/tests/expressions/tests.py#L1572
Should I add the testcase on top of branch master? Should I do a github pull request?
This happens with sqlite and postgresql (AFAIK, does not depend on database type).
This bug happens on latest Django 2.2 (from git) but does not happen on Django 3.0.8 from pypi.
Wrong result "from the database" is a serious bug, please fix it in Django 2.2 LTS too.
Change History (3)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
Description: | modified (diff) |
---|
comment:3 by , 4 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This was fixed in fb3f034f1c63160c0ff13c609acd01c18be12f80, see #30158. Django 2.2 is in extended support so it receives only security fixes. Per our backporting policy this means it doesn't qualify for a backport to 2.2.x anymore. See Django’s release process for more details.
This is the testcase: https://github.com/zt-initech/django/blob/ticket_31830/tests/expressions/tests.py#L1572
Should I add the testcase on top of branch master? Should I do a github pull request?