Skip to content

Commit bbba180

Browse files
committed
Edit Error message
1 parent 30d0519 commit bbba180

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

django_mongodb_backend/indexes.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ def check(self, model, connection):
189189
if field_name in viewed:
190190
errors.append(
191191
Error(
192-
f"Field '{field_name}' is defined more than once. Vector and filter"
193-
" fields must use distinct field names.",
192+
f"Field '{field_name}' is defined more than once. Vector and filter "
193+
"fields must use distinct field names.",
194194
obj=self,
195-
hint="If you need different configurations for the same field,"
196-
" create separate indexes.",
195+
hint="If you need different configurations for the same field, "
196+
"create separate indexes.",
197197
id=f"{self._error_id_prefix}.E005",
198198
)
199199
)
@@ -213,7 +213,10 @@ def check(self, model, connection):
213213
if not isinstance(field_.base_field, FloatField | DecimalField):
214214
errors.append(
215215
Error(
216-
"Base type must be Float or Decimal.",
216+
"An Atlas vector search index requires the base "
217+
"field of ArrayField Model.field_name "
218+
"to be FloatField or DecimalField but "
219+
f"is {field_.base_field.get_internal_type()}.",
217220
obj=self,
218221
id=f"{self._error_id_prefix}.E002",
219222
)

tests/indexes_/test_checks.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ class Meta:
102102
errors,
103103
[
104104
checks.Error(
105-
"Base type must be Float or Decimal.",
105+
"An Atlas vector search index requires the base field of ArrayField "
106+
"Model.field_name to be FloatField or DecimalField but is CharField.",
106107
id="django_mongodb_backend.indexes.VectorSearchIndex.E002",
107108
obj=Article._meta.indexes[0],
108109
)
@@ -202,8 +203,8 @@ class Meta:
202203
errors,
203204
[
204205
checks.Error(
205-
"Field 'vector_data' is defined more than once. Vector and filter"
206-
" fields must use distinct field names.",
206+
"Field 'vector_data' is defined more than once. Vector and filter "
207+
"fields must use distinct field names.",
207208
id="django_mongodb_backend.indexes.VectorSearchIndex.E005",
208209
hint="If you need different configurations for the same field,"
209210
" create separate indexes.",

0 commit comments

Comments
 (0)