Repository navigation
feat: add an opt-in query_typed option for the postgres backends - #15
Closed
orlandoc01 wants to merge 2 commits into
Closed
orlandoc01 wants to merge 2 commits into
orlandoc01 wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MFwFfjtmH1EyBCTd1jf6C4
Fixes the pg_catalog lowercase fallback, maps pseudo-types such as any to the prepared path, and corrects character varying to VARCHAR. Merges the typed static and dynamic generators into the existing ones behind a bind mode, dedupes the dynamic bind arms and test query parsing across backends, and adds live multi-type coverage to the type-mapping postgres crates. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MFwFfjtmH1EyBCTd1jf6C4
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.
Summary
Adds an opt-in
query_typed: trueplugin option for thepostgres,tokio-postgres, anddeadpool-postgresbackends (upstream tunamaguro/sqlc-gen-rust#61).When enabled, plain static-query functions and
-- :ifdynamic-filter functions bind parameters by their PostgreSQL type OID and execute with the driver'squery_typed*APIs, so a call is one round trip instead of prepare + execute. Dynamic-filter queries benefit most, since their SQL is built at runtime and could never be prepared ahead.prepare_<fn>and<fn>_withare unchanged, so callers who want prepared statements keep them.:exec/:execrows/:execresultdrain a typed row stream and readrows_affected; the async backends needfutures-util, which the_streamhelpers already required.postgres_types::Typeconstant (user enums, domains,citext,hstore, pseudo-types such asany) is generated exactly as before, even with the flag on.deadpool-postgres0.14'sGenericClientpredates the typed methods, so its typed plain functions take the pooledClient; pooled transactions keep usingprepare_<fn>/<fn>_with.The option is enabled in
sqlc.yamlfor thedynamic-filterandtype-mappingpostgres example crates so CI runs both the typed and fallback paths against a live database. Other example crates stay on the prepared path.Also dedupes the postgres static/dynamic generators behind a bind mode, shares the dynamic bind-arm scaffolding across sqlx/rusqlite/postgres, and centralises test query parsing in
test_support.Test plan
just check-localcargo testfor the six typed example crates against a live PostgreSQL 17 (POSTGRES_DATABASE_URL):one/:many/:exec/:execrowson all three backends, arrays,pg_catalog.spellings, zero-parameter queries, enum andanyfallback, dynamic-filter typed helper, flag-off unchangedUpdateKnownTypesin the three type-mapping postgres crates binding arrays, timestamps, date, uuid, json/jsonb, bytea, text, bool, and float8 through the typed path🤖 Generated with Claude Code
https://claude.ai/code/session_01MFwFfjtmH1EyBCTd1jf6C4