1
- from django .core .exceptions import EmptyResultSet , FullResultSet
2
1
from django .db import NotSupportedError
3
2
from django .db .models import Index
4
3
from django .db .models .fields .related_lookups import In
@@ -47,10 +46,6 @@ def in_idx(self, compiler, connection):
47
46
48
47
49
48
def 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 )
54
49
if self .connector == AND :
55
50
operator = "$and"
56
51
elif self .connector == XOR :
@@ -63,31 +58,14 @@ def where_node_idx(self, compiler, connection):
63
58
raise NotSupportedError ("MongoDB does not support the '~' operator in indexes." )
64
59
children_mql = []
65
60
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 )
83
63
if len (children_mql ) == 1 :
84
64
mql = children_mql [0 ]
85
65
elif len (children_mql ) > 1 :
86
66
mql = {operator : children_mql }
87
67
else :
88
68
mql = {}
89
- if not mql :
90
- raise FullResultSet
91
69
return mql
92
70
93
71
0 commit comments