﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31830	wrong result of QuerySet count() caused by incorrect handling of EmptyResultSet inside Exists() inside OR	zt_initech	nobody	"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."	Bug	new	Database layer (models, ORM)	2.2	Normal				Unreviewed	0	0	0	0	0	0
