|
1 |
| -from collections import defaultdict |
2 | 1 | import itertools
|
3 | 2 | from collections import defaultdict
|
4 | 3 |
|
@@ -109,52 +108,6 @@ def where_node_idx(self, compiler, connection):
|
109 | 108 | return mql
|
110 | 109 |
|
111 | 110 |
|
112 |
| -def get_pymongo_index_model( |
113 |
| - self, |
114 |
| - model, |
115 |
| - schema_editor, |
116 |
| - *, |
117 |
| - field=None, |
118 |
| - unique=False, |
119 |
| - column_prefix="", |
120 |
| -): |
121 |
| - if self.contains_expressions: |
122 |
| - return None |
123 |
| - kwargs = {} |
124 |
| - filter_expression = defaultdict(dict) |
125 |
| - if self.condition: |
126 |
| - filter_expression.update(self._get_condition_mql(model, schema_editor)) |
127 |
| - if unique: |
128 |
| - kwargs["unique"] = True |
129 |
| - # Indexing on $type matches the value of most SQL databases by |
130 |
| - # allowing multiple null values for the unique constraint. |
131 |
| - if field: |
132 |
| - column = column_prefix + field.column |
133 |
| - filter_expression[column].update({"$type": field.db_type(schema_editor.connection)}) |
134 |
| - else: |
135 |
| - for field_name, _ in self.fields_orders: |
136 |
| - field_ = model._meta.get_field(field_name) |
137 |
| - filter_expression[field_.column].update( |
138 |
| - {"$type": field_.db_type(schema_editor.connection)} |
139 |
| - ) |
140 |
| - if filter_expression: |
141 |
| - kwargs["partialFilterExpression"] = filter_expression |
142 |
| - index_orders = ( |
143 |
| - [(column_prefix + field.column, ASCENDING)] |
144 |
| - if field |
145 |
| - else [ |
146 |
| - # order is "" if ASCENDING or "DESC" if DESCENDING (see |
147 |
| - # django.db.models.indexes.Index.fields_orders). |
148 |
| - ( |
149 |
| - column_prefix + model._meta.get_field(field_name).column, |
150 |
| - ASCENDING if order == "" else DESCENDING, |
151 |
| - ) |
152 |
| - for field_name, order in self.fields_orders |
153 |
| - ] |
154 |
| - ) |
155 |
| - return IndexModel(index_orders, name=self.name, **kwargs) |
156 |
| - |
157 |
| - |
158 | 111 | class SearchIndex(Index):
|
159 | 112 | suffix = "search"
|
160 | 113 |
|
|
0 commit comments