Skip to content

Commit

Permalink
Corrected errors in update
Browse files Browse the repository at this point in the history
  • Loading branch information
perrito666 committed Jun 26, 2018
1 parent bd7e1fa commit 855a875
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion db/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func (ec *ExpresionChain) render(raw bool) (string, []interface{}, error) {
if len(expresion) == 0 {
return "", nil, errors.Errorf("empty update expresion")
}
query = fmt.Sprintf("UPDATE %s SET (%s)",
query = fmt.Sprintf("UPDATE %s SET %s",
ec.table, ec.mainOperation.expresion)
args = append(args, ec.mainOperation.arguments...)
// SELECT, DELETE
Expand Down
4 changes: 2 additions & 2 deletions db/chain/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ func TestExpresionChain_Render(t *testing.T) {
AndWhere("field2 = ?", 2).
AndWhere("field3 > ?", "pajarito").
Join("another_convenient_table ON pirulo = ?", "unpirulo"),
want: "UPDATE $1 SET (field1 = $2, field3 = $3) JOIN another_convenient_table ON pirulo = $4 WHERE field1 > $5 AND field2 = $6 AND field3 > $7",
wantArgs: []interface{}{"convenient_table", "value2", 9, "unpirulo", 1, 2, "pajarito"},
want: "UPDATE convenient_table SET field1 = $1, field3 = $2 JOIN another_convenient_table ON pirulo = $3 WHERE field1 > $4 AND field2 = $5 AND field3 > $6",
wantArgs: []interface{}{"value2", 9, "unpirulo", 1, 2, "pajarito"},
wantErr: false,
},
}
Expand Down

0 comments on commit 855a875

Please sign in to comment.