sea-orm icon indicating copy to clipboard operation
sea-orm copied to clipboard

Upcoming SQLx Breakage: `TransactionManager` trait reexport is being deleted in 0.9.0

Open abonander opened this issue 5 months ago • 1 comments

This is a friendly warning that the TransactionManager trait currently being used by this crate will no longer be re-exported by SQLx in the 0.9.0 release.

Reposting the discussion in https://github.com/SeaQL/sea-orm/pull/2562#issuecomment-2808177497 for visibility since it was never acknowledged by a maintainer.

I see why it's necessary: you're using your own RAII wrapper that's not compatible with sqlx::Transaction. I can see the motivation for that.

The issue is that TransactionManager is an implementation detail that needs to remain flexible so we can do things like add begin_with backwards-compatibly. That's why it's a #[doc(hidden)] trait.

We need to figure out a long-term solution here:

  • You could use the trait from sqlx-core with a pinned version, but then you have to cut a release every time SQLx does.

  • You could implement your own transaction handling and execute BEGIN, COMMIT and ROLLBACK statements directly. This offers SeaORM the most potential flexibility. At the end of the day, it's not that complicated. You could copy the routines that SQLx uses if you want.

  • We could design a non-RAII transaction begin/end API for SQLx. My main concern with this is that the RAII-based API should still be the preferred method for 99% of use-cases, so the design should make that obvious.

I'm also wondering if it's worth just merging TransactionManager into the Connection trait since that's probably where those methods belong.

abonander avatar May 19 '25 23:05 abonander