Skip to content

Commit 5eabd83

Browse files
committed
Handle empty exist subqueries.
1 parent bfb40b7 commit 5eabd83

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

django_mongodb/expressions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ def subquery(self, compiler, connection, lookup_name=None):
173173

174174

175175
def exists(self, compiler, connection):
176-
lhs_mql = subquery(self, compiler, connection)
176+
try:
177+
lhs_mql = subquery(self, compiler, connection)
178+
except EmptyResultSet:
179+
return Value(False).as_mql(compiler, connection)
177180
return connection.mongo_operators["isnull"](lhs_mql, False)
178181

179182

0 commit comments

Comments
 (0)