Skip to content

Commit ef075c9

Browse files
committed
Return None if the index cannot be created
1 parent 9e33cff commit ef075c9

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

django_mongodb_backend/indexes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ def search_index_data_types(self, field, db_type):
147147
def get_pymongo_index_model(
148148
self, model, schema_editor, field=None, unique=False, column_prefix=""
149149
):
150-
errors = self.check(model, schema_editor.connection)
151-
if errors:
150+
if not schema_editor.connection.features.supports_atlas_search:
152151
return None
153152
fields = {}
154153
for field_name, _ in self.fields_orders:
@@ -243,8 +242,7 @@ def deconstruct(self):
243242
def get_pymongo_index_model(
244243
self, model, schema_editor, field=None, unique=False, column_prefix=""
245244
):
246-
errors = self.check(model, schema_editor.connection)
247-
if errors:
245+
if not schema_editor.connection.features.supports_atlas_search:
248246
return None
249247
similarities = (
250248
itertools.cycle([self.similarities])

django_mongodb_backend/schema.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,6 @@ def alter_unique_together(
263263
def add_index(
264264
self, model, index, *, field=None, unique=False, column_prefix="", parent_model=None
265265
):
266-
# Check if the index can be created.
267-
if hasattr(index, "check") and index.check(model, self.connection):
268-
return
269266
idx = index.get_pymongo_index_model(
270267
model, schema_editor=self, field=field, unique=unique, column_prefix=column_prefix
271268
)

0 commit comments

Comments
 (0)