Skip to content

Commit a3efe35

Browse files
committed
Remove duplicate function
1 parent 2865e13 commit a3efe35

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

django_mongodb_backend/indexes.py

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from collections import defaultdict
21
import itertools
32
from collections import defaultdict
43

@@ -109,52 +108,6 @@ def where_node_idx(self, compiler, connection):
109108
return mql
110109

111110

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-
158111
class SearchIndex(Index):
159112
suffix = "search"
160113

0 commit comments

Comments
 (0)