From e02f51643b0c8fb8d356db12ee41787457ee28e8 Mon Sep 17 00:00:00 2001 From: Reza Date: Tue, 29 Oct 2024 12:56:55 +0100 Subject: [PATCH] validator unique columns --- lib/validation/validators.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/validation/validators.go b/lib/validation/validators.go index a260eaf..08b60f0 100644 --- a/lib/validation/validators.go +++ b/lib/validation/validators.go @@ -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 { @@ -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) } } }