1- from django .core .exceptions import EmptyResultSet , FullResultSet
21from django .db import NotSupportedError
32from django .db .models import Index
43from django .db .models .fields .related_lookups import In
@@ -47,10 +46,6 @@ def in_idx(self, compiler, connection):
4746
4847
4948def where_node_idx (self , compiler , connection ):
50- if self .connector == AND :
51- full_needed , empty_needed = len (self .children ), 1
52- else :
53- full_needed , empty_needed = 1 , len (self .children )
5449 if self .connector == AND :
5550 operator = "$and"
5651 elif self .connector == XOR :
@@ -63,31 +58,14 @@ def where_node_idx(self, compiler, connection):
6358 raise NotSupportedError ("MongoDB does not support the '~' operator in indexes." )
6459 children_mql = []
6560 for child in self .children :
66- try :
67- mql = child .as_mql_idx (compiler , connection )
68- except EmptyResultSet :
69- empty_needed -= 1
70- except FullResultSet :
71- full_needed -= 1
72- else :
73- if mql :
74- children_mql .append (mql )
75- else :
76- full_needed -= 1
77-
78- if empty_needed == 0 :
79- raise EmptyResultSet
80- if full_needed == 0 :
81- return {}
82-
61+ mql = child .as_mql_idx (compiler , connection )
62+ children_mql .append (mql )
8363 if len (children_mql ) == 1 :
8464 mql = children_mql [0 ]
8565 elif len (children_mql ) > 1 :
8666 mql = {operator : children_mql }
8767 else :
8868 mql = {}
89- if not mql :
90- raise FullResultSet
9169 return mql
9270
9371
0 commit comments