Skip to content

Relax constraint on VALUE clause expansion #962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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