Skip to content

Commit a05a998

Browse files
committed
Edits
1 parent 9d7a737 commit a05a998

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

django_mongodb_backend/indexes.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def check(self, model, connection):
127127

128128
def search_index_data_types(self, db_type):
129129
"""
130-
Map a model field's internal type to search index type.
130+
Map a model field's type to search index type.
131131
Reference: https://www.mongodb.com/docs/atlas/atlas-search/define-field-mappings/#data-types
132132
"""
133133
if db_type in {"double", "int", "long"}:
@@ -183,11 +183,11 @@ def check(self, model, connection):
183183
errors = super().check(model, connection)
184184
expected_similarities = 0
185185
for field_name, _ in self.fields_orders:
186-
field_ = model._meta.get_field(field_name)
187-
if isinstance(field_, ArrayField):
186+
field = model._meta.get_field(field_name)
187+
if isinstance(field, ArrayField):
188188
expected_similarities += 1
189189
try:
190-
int(field_.size)
190+
int(field.size)
191191
except (ValueError, TypeError):
192192
errors.append(
193193
Error(
@@ -196,27 +196,27 @@ def check(self, model, connection):
196196
id=f"{self._error_id_prefix}.E002",
197197
)
198198
)
199-
if not isinstance(field_.base_field, FloatField | IntegerField):
199+
if not isinstance(field.base_field, FloatField | IntegerField):
200200
errors.append(
201201
Error(
202202
"VectorSearchIndex requires the base field of "
203-
f"ArrayField '{field_.name}' to be FloatField or "
203+
f"ArrayField '{field.name}' to be FloatField or "
204204
"IntegerField but is "
205-
f"{field_.base_field.get_internal_type()}.",
205+
f"{field.base_field.get_internal_type()}.",
206206
obj=model,
207207
id=f"{self._error_id_prefix}.E003",
208208
)
209209
)
210210
else:
211-
search_type = self.search_index_data_types(field_.db_type(connection))
211+
search_type = self.search_index_data_types(field.db_type(connection))
212212
# filter - for fields that contain boolean, date, objectId,
213213
# numeric, string, or UUID values. Reference:
214214
# https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-type/#atlas-vector-search-index-fields
215215
if search_type not in {"number", "string", "boolean", "objectId", "uuid", "date"}:
216216
errors.append(
217217
Error(
218218
"VectorSearchIndex does not support "
219-
f"{field_.get_internal_type()} '{field_name}'.",
219+
f"{field.get_internal_type()} '{field_name}'.",
220220
obj=model,
221221
id=f"{self._error_id_prefix}.E004",
222222
)

0 commit comments

Comments
 (0)