Skip to content
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

fix: named params contribute to batch parameter count #1841

Merged
merged 2 commits into from
Sep 16, 2022

Conversation

chrisyxlee
Copy link
Contributor

The batch validation code was only allowing numbered params contribute to the total parameter count of a query, which prevented batch queries with only named parameters from successfully generating code.

Fixes #1625

Comment on lines 50 to 54
namedFunc := astutils.Search(n, named.IsParamFunc)
namedSign := astutils.Search(n, named.IsParamSign)
if len(namedFunc.Items)+len(namedSign.Items) > 0 {
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As some point, we rewrite the AST to change named parameters into normal parameter references. We probably just want to move the validate batch call so that it happens after that process. Then it doesn't need to know anything about named parameters.

Copy link
Collaborator

@kyleconroy kyleconroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good. I merged your other PR which now conflicts with this one. Once you rebase I'll get it merged.

@chrisyxlee
Copy link
Contributor Author

merge conflicts with myself

@kyleconroy kyleconroy merged commit 1a28c29 into sqlc-dev:main Sep 16, 2022
@chrisyxlee chrisyxlee deleted the chris/batch-named branch September 20, 2022 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Batch queries with only named parameters fail with :batch* commands require parameters
2 participants