Skip to content

feat: support PoolConnection via AsExecutor trait#4

Merged
jrandolf merged 1 commit intomainfrom
feat/as-executor-trait
Apr 13, 2026
Merged

feat: support PoolConnection via AsExecutor trait#4
jrandolf merged 1 commit intomainfrom
feat/as-executor-trait

Conversation

@jrandolf
Copy link
Copy Markdown
Contributor

Summary

  • Replaces the for<'c> &'c mut E: sqlx::Executor<'c, Database = Postgres> bound on Queries<E> with a generated AsExecutor trait.
  • AsExecutor has impls for PgPool, &PgPool, PgConnection, Transaction<'_, Postgres>, PoolConnection<Postgres>, and &mut T — covering all eight call shapes (owned + &mut).
  • Fixes a latent bug: the README previously claimed Queries::new(&pool) and Queries::new(&mut tx) worked, but neither actually type-checked against the old bound. Only Queries::new(conn) with owned PgConnection did.
  • Also fixes broken enums and batch example mains that didn't match the current codegen (struct params / stream returns).

Why the previous bound failed

sqlx has a commented-out impl Executor for &mut PoolConnection<DB> in sqlx-core/src/pool/executor.rs citing trait-resolver overflow in the generic blanket form. AsExecutor sidesteps that by providing concrete per-type impls that yield &mut PgConnection directly.

Test plan

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace (snapshots; integration tests require DATABASE_URL)
  • cargo build --target wasm32-wasip1
  • e2e test (testcontainers Postgres) — compiles and runs generated code for all annotation types

🤖 Generated with Claude Code

…trait

Replace the `for<'c> &'c mut E: sqlx::Executor<'c, Database = Postgres>`
bound on `Queries<E>` with a generated `AsExecutor` trait. The new trait
has impls for `PgPool`, `&PgPool`, `PgConnection`, `Transaction`,
`PoolConnection`, and `&mut T` — fixing the gap where `PoolConnection`
deref'd executors previously required a manual `&mut *conn` at call sites,
and also the cases `&PgPool`, `&mut PgConnection`, and `&mut Transaction`
which the README claimed worked but didn't type-check.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jrandolf jrandolf merged commit 0db4bde into main Apr 13, 2026
2 checks passed
@jrandolf jrandolf deleted the feat/as-executor-trait branch April 13, 2026 10:05
jrandolf added a commit that referenced this pull request Apr 13, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.1.1](v0.1.0...v0.1.1)
(2026-04-13)


### Features

* Support PoolConnection via AsExecutor trait
([#4](#4))
([0db4bde](0db4bde))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
jrandolf added a commit that referenced this pull request Apr 13, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.1.4](v0.1.3...v0.1.4)
(2026-04-13)


### Features

* Add Queries::into_inner
([#6](#6))
([5e5058e](5e5058e))
* Initial commit
([e8693f3](e8693f3))
* Support PoolConnection via AsExecutor trait
([#4](#4))
([0db4bde](0db4bde))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

1 participant