feat: Use query_typed and variants#305
Draft
Destructor17 wants to merge 2 commits into
Draft
Conversation
This was referenced May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #283
As described in rust-postgres/rust-postgres#1147, only
query_typedand variants are usable with some connection pools because non-typedqueryprepares statements just to obtain param types.This PR uses
query_typedif prepared statements are not needed. Such scenario is common for serverless apps. For example code generated by this fork works well with Cloudflare Hyperdrive.Yeah also it should improve performance a bit if prepared statements are not used
However there are a few things that need to be discussed:
postgres_types::Typeis surprisingly rich. How do we express it during codegen? I covered some simple types but that's not enough. Maybe there is some way to serialize it? Or, maybe we should fall back to non-typedqueryif a type can't be expressed?queryfallback will not be used, non-typedparamscan also be removed.clorinde::client::async_::rawuses thatIntoIteratorforparamsinstead of a simple slice likeclorinde::client::async_::one? I have not managed to useIntoIteratorfortyped_paramsbecause it makes futures non-Send (I believe it also should be tested), while slices work just nicesrc/codegen/client.rsbecomes too bloated? I just added typed variant for almost every method of every client implementation and trait - lots of code that may be generated using some # magic in quote! instead of repeating thingsHow has this been tested?
I have not ran tests or benchmarks yet, and have not tried to generate sync code, but this seem to work.
At the time of writing this PR is a draft
The following has been done
feat:,fix:,chore:, ordocs:src, codegen for the repo has been run withcargo run --package test_integration -- --apply-codegenTests and linting
cargo fmtcargo test --allandcargo clippy