added test for partially matched table name/alias as suffix

This commit is contained in:
Gani Georgiev committed 2025-01-12 13:24:33 +02:00
1 parent f4108cb354
commit e4d637e6e0
2 files changed
+10 -2

No files matched your search

+3 -2
View File
@@ -64,8 +64,9 @@ func NormalizeUniqueIndexError(err error, tableOrAlias string, fieldNames []stri
normalizedErrs := validation.Errors{}
for _, name := range fieldNames {
// note: extra space to exclude other fields starting with the current field name
if strings.Contains(msg, strings.ToLower(tableOrAlias+"."+name+" ")) {
// note: extra spaces to exclude table name with suffix matching the current one
// OR other fields starting with the current field name
if strings.Contains(msg, strings.ToLower(" "+tableOrAlias+"."+name+" ")) {
normalizedErrs[name] = validation.NewError("validation_not_unique", "Value must be unique")
}
}