@@ -127,7 +127,7 @@ def check(self, model, connection):
127
127
128
128
def search_index_data_types (self , db_type ):
129
129
"""
130
- Map a model field's internal type to search index type.
130
+ Map a model field's type to search index type.
131
131
Reference: https://www.mongodb.com/docs/atlas/atlas-search/define-field-mappings/#data-types
132
132
"""
133
133
if db_type in {"double" , "int" , "long" }:
@@ -183,11 +183,11 @@ def check(self, model, connection):
183
183
errors = super ().check (model , connection )
184
184
expected_similarities = 0
185
185
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 ):
188
188
expected_similarities += 1
189
189
try :
190
- int (field_ .size )
190
+ int (field .size )
191
191
except (ValueError , TypeError ):
192
192
errors .append (
193
193
Error (
@@ -196,27 +196,27 @@ def check(self, model, connection):
196
196
id = f"{ self ._error_id_prefix } .E002" ,
197
197
)
198
198
)
199
- if not isinstance (field_ .base_field , FloatField | IntegerField ):
199
+ if not isinstance (field .base_field , FloatField | IntegerField ):
200
200
errors .append (
201
201
Error (
202
202
"VectorSearchIndex requires the base field of "
203
- f"ArrayField '{ field_ .name } ' to be FloatField or "
203
+ f"ArrayField '{ field .name } ' to be FloatField or "
204
204
"IntegerField but is "
205
- f"{ field_ .base_field .get_internal_type ()} ." ,
205
+ f"{ field .base_field .get_internal_type ()} ." ,
206
206
obj = model ,
207
207
id = f"{ self ._error_id_prefix } .E003" ,
208
208
)
209
209
)
210
210
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 ))
212
212
# filter - for fields that contain boolean, date, objectId,
213
213
# numeric, string, or UUID values. Reference:
214
214
# https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-type/#atlas-vector-search-index-fields
215
215
if search_type not in {"number" , "string" , "boolean" , "objectId" , "uuid" , "date" }:
216
216
errors .append (
217
217
Error (
218
218
"VectorSearchIndex does not support "
219
- f"{ field_ .get_internal_type ()} '{ field_name } '." ,
219
+ f"{ field .get_internal_type ()} '{ field_name } '." ,
220
220
obj = model ,
221
221
id = f"{ self ._error_id_prefix } .E004" ,
222
222
)
0 commit comments