Skip to content

Commit

Permalink
Fix: Table contains VALUES
Browse files Browse the repository at this point in the history
  • Loading branch information
QuangTung97 committed Apr 28, 2021
1 parent b20d679 commit 3ab43db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion named.go
Expand Up @@ -224,7 +224,7 @@ func bindStruct(bindType int, query string, arg interface{}, m *reflectx.Mapper)
return bound, arglist, nil
}

var valuesReg = regexp.MustCompile(`(?i)VALUES\s*\(`)
var valuesReg = regexp.MustCompile(`\)\s*(?i)VALUES\s*\(`)

func findMatchingClosingBracketIndex(s string) int {
count := 0
Expand Down
6 changes: 6 additions & 0 deletions named_test.go
Expand Up @@ -385,6 +385,12 @@ func TestFixBounds(t *testing.T) {
expect: `INSERT INTO foo (a, b) VALUES (:a, YEAR(NOW())`,
loop: 2,
},
{
name: `table with "values" at the end`,
query: `INSERT INTO table_values (a, b) VALUES (:a, :b)`,
expect: `INSERT INTO table_values (a, b) VALUES (:a, :b),(:a, :b)`,
loop: 2,
},
}

for _, tc := range table {
Expand Down

0 comments on commit 3ab43db

Please sign in to comment.