mirror of https://github.com/go-gorm/gorm.git
fix: SQL `UPDATE SET` is missing spaces
This commit is contained in:
parent
6bef318891
commit
e9c3b25552
|
@ -18,9 +18,12 @@ func (set Set) Build(builder Builder) {
|
|||
for idx, assignment := range set {
|
||||
if idx > 0 {
|
||||
builder.WriteByte(',')
|
||||
builder.WriteByte(' ')
|
||||
}
|
||||
builder.WriteQuoted(assignment.Column)
|
||||
builder.WriteByte(' ')
|
||||
builder.WriteByte('=')
|
||||
builder.WriteByte(' ')
|
||||
builder.AddVar(builder, assignment.Value)
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -32,6 +32,18 @@ func TestSet(t *testing.T) {
|
|||
"UPDATE `users` SET `name` = ?",
|
||||
[]interface{}{"jinzhu"},
|
||||
},
|
||||
{
|
||||
[]clause.Interface{
|
||||
clause.Update{},
|
||||
clause.Set([]clause.Assignment{{clause.PrimaryColumn, 1}}),
|
||||
clause.Set([]clause.Assignment{
|
||||
{clause.Column{Name: "name"}, "jinzhu"},
|
||||
{clause.Column{Name: "age"}, 18},
|
||||
}),
|
||||
},
|
||||
"UPDATE `users` SET `name` = ?, `age` = ?",
|
||||
[]interface{}{"jinzhu", 18},
|
||||
},
|
||||
}
|
||||
|
||||
for idx, result := range results {
|
||||
|
|
Loading…
Reference in New Issue