Skip to content

Commit 3ab43db

Browse files
committed
Fix: Table contains VALUES
1 parent b20d679 commit 3ab43db

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

named.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func bindStruct(bindType int, query string, arg interface{}, m *reflectx.Mapper)
224224
return bound, arglist, nil
225225
}
226226

227-
var valuesReg = regexp.MustCompile(`(?i)VALUES\s*\(`)
227+
var valuesReg = regexp.MustCompile(`\)\s*(?i)VALUES\s*\(`)
228228

229229
func findMatchingClosingBracketIndex(s string) int {
230230
count := 0

named_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ func TestFixBounds(t *testing.T) {
385385
expect: `INSERT INTO foo (a, b) VALUES (:a, YEAR(NOW())`,
386386
loop: 2,
387387
},
388+
{
389+
name: `table with "values" at the end`,
390+
query: `INSERT INTO table_values (a, b) VALUES (:a, :b)`,
391+
expect: `INSERT INTO table_values (a, b) VALUES (:a, :b),(:a, :b)`,
392+
loop: 2,
393+
},
388394
}
389395

390396
for _, tc := range table {

0 commit comments

Comments
 (0)