@@ -40,28 +40,6 @@ def builtin_lookup_idx(self, compiler, connection):
40
40
return {lhs_mql : {operator : value }}
41
41
42
42
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
-
65
43
def get_pymongo_index_model (self , model , schema_editor , field = None , unique = False , column_prefix = "" ):
66
44
"""Return a pymongo IndexModel for this Django Index."""
67
45
if self .contains_expressions :
@@ -101,6 +79,28 @@ def get_pymongo_index_model(self, model, schema_editor, field=None, unique=False
101
79
return IndexModel (index_orders , name = self .name , ** kwargs )
102
80
103
81
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
+
104
104
def register_indexes ():
105
105
BuiltinLookup .as_mql_idx = builtin_lookup_idx
106
106
Index ._get_condition_mql = _get_condition_mql
0 commit comments