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 Initial Version
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
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.
I have a testcase I'll push to github when I have a ticket number.
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.