Skip to content

Commit

Permalink
validator unique columns
Browse files Browse the repository at this point in the history
  • Loading branch information
iesreza committed Oct 29, 2024
1 parent e96a15c commit e02f516
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/validation/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var DBValidators = map[*regexp.Regexp]func(match []string, value *generic.Value,
func uniqueColumnsValidator(match []string, value *generic.Value, stmt *gorm.Statement, field *schema.Field) error {
var columns = strings.Split(match[1], ",")
evo.Dump(columns)

evo.Dump(match)
var model = db.Debug().Table(stmt.Table)
for _, item := range stmt.Schema.Fields {
for _, column := range columns {
Expand All @@ -39,7 +39,7 @@ func uniqueColumnsValidator(match []string, value *generic.Value, stmt *gorm.Sta
if zero {
return nil
}
model = model.Where(column+" =?", dst)
model = model.Where("`"+item.DataType+"` = ?", dst)
}
}
}
Expand Down

0 comments on commit e02f516

Please sign in to comment.