@@ -40,28 +40,6 @@ def builtin_lookup_idx(self, compiler, connection):
4040 return {lhs_mql : {operator : value }}
4141
4242
43- def where_node_idx (self , compiler , connection ):
44- if self .connector == AND :
45- operator = "$and"
46- elif self .connector == XOR :
47- raise NotSupportedError ("MongoDB does not support the '^' operator lookup in indexes." )
48- else :
49- operator = "$or"
50- if self .negated :
51- raise NotSupportedError ("MongoDB does not support the '~' operator in indexes." )
52- children_mql = []
53- for child in self .children :
54- mql = child .as_mql_idx (compiler , connection )
55- children_mql .append (mql )
56- if len (children_mql ) == 1 :
57- mql = children_mql [0 ]
58- elif len (children_mql ) > 1 :
59- mql = {operator : children_mql }
60- else :
61- mql = {}
62- return mql
63-
64-
6543def get_pymongo_index_model (self , model , schema_editor , field = None , unique = False , column_prefix = "" ):
6644 """Return a pymongo IndexModel for this Django Index."""
6745 if self .contains_expressions :
@@ -101,6 +79,28 @@ def get_pymongo_index_model(self, model, schema_editor, field=None, unique=False
10179 return IndexModel (index_orders , name = self .name , ** kwargs )
10280
10381
82+ def where_node_idx (self , compiler , connection ):
83+ if self .connector == AND :
84+ operator = "$and"
85+ elif self .connector == XOR :
86+ raise NotSupportedError ("MongoDB does not support the '^' operator lookup in indexes." )
87+ else :
88+ operator = "$or"
89+ if self .negated :
90+ raise NotSupportedError ("MongoDB does not support the '~' operator in indexes." )
91+ children_mql = []
92+ for child in self .children :
93+ mql = child .as_mql_idx (compiler , connection )
94+ children_mql .append (mql )
95+ if len (children_mql ) == 1 :
96+ mql = children_mql [0 ]
97+ elif len (children_mql ) > 1 :
98+ mql = {operator : children_mql }
99+ else :
100+ mql = {}
101+ return mql
102+
103+
104104def register_indexes ():
105105 BuiltinLookup .as_mql_idx = builtin_lookup_idx
106106 Index ._get_condition_mql = _get_condition_mql
0 commit comments