Skip to content

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