Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion named.go
Original file line number Diff line number Diff line change
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(`\)\s*(?i)VALUES\s*\(`)
var valuesReg = regexp.MustCompile(`(?i)\WVALUES\s*\(`)

func findMatchingClosingBracketIndex(s string) int {
count := 0
Expand Down
24 changes: 24 additions & 0 deletions named_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,30 @@ func TestFixBounds(t *testing.T) {
)`,
loop: 2,
},
{
name: "use of VALUES not for insert",
query: `
UPDATE t
SET
foo = u.foo,
bar = u.bar
FROM (
VALUES (:id, :foo, :bar)
) AS u(id, foo, bar)
WHERE t.id = u.id
`,
expect: `
UPDATE t
SET
foo = u.foo,
bar = u.bar
FROM (
VALUES (:id, :foo, :bar),(:id, :foo, :bar)
) AS u(id, foo, bar)
WHERE t.id = u.id
`,
loop: 2,
},
}

for _, tc := range table {
Expand Down