Skip to content

Support ParameterDescription (statement variant) #221

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

Closed
uasan opened this issue Sep 2, 2021 · 2 comments · Fixed by #259
Closed

Support ParameterDescription (statement variant) #221

uasan opened this issue Sep 2, 2021 · 2 comments · Fixed by #259
Labels
enhancement New feature or request

Comments

@uasan
Copy link

uasan commented Sep 2, 2021

Hello.

The documentation says:

The Describe message (statement variant) specifies the name of an existing prepared statement (or an empty string for the unnamed prepared statement). The response is a ParameterDescription message describing the parameters needed by the statement
https://www.postgresql.org/docs/13/protocol-flow.html

This means that you will get a list of the types of all input parameters.
Then you just need to encode all the input parameters in accordance with the types that you received from this response.

Then this query will work correctly:

sql`SELECT ${[1, 2, 3]}::int[]`
@porsager porsager added the enhancement New feature or request label Sep 10, 2021
@porsager
Copy link
Owner

Yeah, doing that only once per prepared statement would be very little overhead, so that's a cool idea!

@uasan
Copy link
Author

uasan commented Sep 10, 2021

You do not need to send an additional request for Describe.
Just need to change the current flow of requests, on such:

send Parse sql
send Describe 'S'
receive ParameterDescription - save result for reuse
receive RowDescription - save result for reuse
send Bind
send Execute

In response ParameterDescription - all oid for param types.
Users will not need to use helper methods such as sql.json(), sql.array() ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants