From 855a875206f590f86fdb19b6cbf86f99d5480508 Mon Sep 17 00:00:00 2001 From: Horacio Duran Date: Tue, 26 Jun 2018 11:34:39 -0300 Subject: [PATCH] Corrected errors in update --- db/chain/chain.go | 2 +- db/chain/chain_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/chain/chain.go b/db/chain/chain.go index fffffe1..4881dc2 100644 --- a/db/chain/chain.go +++ b/db/chain/chain.go @@ -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 diff --git a/db/chain/chain_test.go b/db/chain/chain_test.go index aa4d372..c4fb145 100644 --- a/db/chain/chain_test.go +++ b/db/chain/chain_test.go @@ -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, }, }