Add invalid data error when building conditions

This commit is contained in:
Jinzhu 2021-01-05 21:01:16 +08:00
parent 00a785cd68
commit 53b3ebdd1d
1 changed files with 49 additions and 48 deletions

View File

@ -308,7 +308,7 @@ func (stmt *Statement) BuildCondition(query interface{}, args ...interface{}) []
}
}
default:
if reflectValue := reflect.Indirect(reflect.ValueOf(arg)); reflectValue.IsValid() {
reflectValue := reflect.Indirect(reflect.ValueOf(arg))
if s, err := schema.Parse(arg, stmt.DB.cacheStore, stmt.DB.NamingStrategy); err == nil {
selectedColumns := map[string]bool{}
if idx == 0 {
@ -354,6 +354,8 @@ func (stmt *Statement) BuildCondition(query interface{}, args ...interface{}) []
if restricted {
break
}
} else if !reflectValue.IsValid() {
stmt.AddError(ErrInvalidData)
} else if len(conds) == 0 {
if len(args) == 1 {
switch reflectValue.Kind() {
@ -374,7 +376,6 @@ func (stmt *Statement) BuildCondition(query interface{}, args ...interface{}) []
}
}
}
}
return conds
}