Skip to content

Conversation

@chrisyxlee
Copy link
Contributor

As a result of #1841 (letting named params contribute to param count), the call to ParamRef will actually fail for queries with mixed usage of numbered and named parameters.

This PR mainly ensures that when the failure occurs, the error surfaced to the user makes it obvious what the issue is. Previously, the error would say :batch* commands require parameters when the actual error is that the parameters are being mixed.

Now it says path/to/query.sql:1:1: could not determine data type of parameter $1 or
path/to/query.sql:15:1: can not mix $1 format with ? format

With this change, I believe mixed parameters are still allowed for non-batch queries, and I'm not sure if I should change that (please let me know through review).

#1625

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.

@chrisyxlee Can you include an example in the comments of a query that will produce the error? I want to make sure we add a test case for this.

@kyleconroy
Copy link
Collaborator

The validation code around parameters has changed a bit. ? place holders aren't allowed anymore in PostgreSQL queries, so I don't think this is needed anymore. If it is, please let me know.

@kyleconroy kyleconroy closed this Jun 7, 2023
@chrisyxlee
Copy link
Contributor Author

Thank you! Apologies for forgetting about this PR -- and sounds good to me. 👍

@chrisyxlee chrisyxlee deleted the chris/surface-errors branch June 7, 2023 20:20
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.

2 participants