fix(statement): The primary key type is not int, but string or uuid (#5984)

This commit is contained in:
胡标 2023-01-16 13:23:27 +08:00
parent 73e3e282dd
commit db0978af99

View File

@ -287,7 +287,12 @@ func (stmt *Statement) BuildCondition(query interface{}, args ...interface{}) []
return nil
}
// The primary key type is not int, but string or uuid (#5984)
//The primary key type is not int, but string or uuid (#5984)
if len(args) == 0 && (!strings.Contains(s, "?") && !strings.Contains(s, "@")) {
// if it is a string, then treats it as primary key
return []clause.Expression{clause.IN{Column: clause.PrimaryColumn, Values: []interface{}{s}}}
}
if len(args) == 0 || (len(args) > 0 && strings.Contains(s, "?")) {
// looks like a where condition
return []clause.Expression{clause.Expr{SQL: s, Vars: args}}