Skip to content

fix: preserve owned lifetime of pool transactions - #39

Open
torchello wants to merge 1 commit into
chmodas:trunkfrom
torchello:codex/upstream-owned-transactions
Open

fix: preserve owned lifetime of pool transactions#39
torchello wants to merge 1 commit into
chmodas:trunkfrom
torchello:codex/upstream-owned-transactions

Conversation

@torchello

Copy link
Copy Markdown

sqlx::Pool::begin() returns an owned Transaction<'static, DB>, but the wrapper shortens that lifetime to the borrow of &self. This prevents returning a transaction from a helper or storing it in an owned guard, even though its connection already belongs to the transaction.

Preserve SQLx's 'static return lifetime. The implementation and transaction behavior remain the same. A regression test requires the owned return type at compile time, drops the originating pool handle, then executes a query and rolls back successfully.

Validation (Rust 1.97.1, SQLx 0.9):

  • cargo test --features "sqlite,runtime-tokio" --test sqlite — 117 passed.
  • cargo clippy --all-targets --all-features -- -D warnings — passed.
  • cargo fmt --all -- --check — passed.

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