Opened 4 years ago
Last modified 4 years ago
#31830 closed Bug
wrong result of QuerySet count() caused by incorrect handling of EmptyResultSet inside Exists() inside OR — at Version 2
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 (2)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
Description: | modified (diff) |
---|
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?