Change buildCondition TableName to struct's TableName when query is interface{} (#2011)

This commit is contained in:
hector 2018-08-19 07:13:16 +08:00 committed by Jinzhu
parent 31ec9255cd
commit 53995294ef
1 changed files with 2 additions and 2 deletions

View File

@ -586,10 +586,10 @@ func (scope *Scope) buildCondition(clause map[string]interface{}, include bool)
scope.Err(fmt.Errorf("invalid query condition: %v", value)) scope.Err(fmt.Errorf("invalid query condition: %v", value))
return return
} }
scopeQuotedTableName := newScope.QuotedTableName()
for _, field := range newScope.Fields() { for _, field := range newScope.Fields() {
if !field.IsIgnored && !field.IsBlank { if !field.IsIgnored && !field.IsBlank {
sqls = append(sqls, fmt.Sprintf("(%v.%v %s %v)", quotedTableName, scope.Quote(field.DBName), equalSQL, scope.AddToVars(field.Field.Interface()))) sqls = append(sqls, fmt.Sprintf("(%v.%v %s %v)", scopeQuotedTableName, scope.Quote(field.DBName), equalSQL, scope.AddToVars(field.Field.Interface())))
} }
} }
return strings.Join(sqls, " AND ") return strings.Join(sqls, " AND ")