Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/transaction options #1924

Closed
wants to merge 7 commits into from

Conversation

xfbs
Copy link

@xfbs xfbs commented Jun 22, 2022

I've stolen the code from #1827, implemented the suggestions and rebased it on top of the current main branch. Missing some unit tests for the Any-related code.

@abonander
Copy link
Collaborator

@andrewwhitehead would you prefer to finish your PR or just see this one merged? I would credit you both in the changelog.

@andrewwhitehead
Copy link
Contributor

I'm happy with merging this one, thanks!

@xfbs xfbs force-pushed the feature/transaction-options branch from 3672b13 to d9987bd Compare July 18, 2022 19:14
@xfbs
Copy link
Author

xfbs commented Jul 18, 2022

FYI, I've just rebased on top of the current main branch and pushed the changes. Hope I didn't break anything.

@abonander abonander added this to the 0.7.0 milestone Sep 3, 2022
@abonander
Copy link
Collaborator

PR target changed to the 0.7 development branch. @xfbs can you rebase again?

@xfbs
Copy link
Author

xfbs commented Sep 15, 2022

I'll rebase this later today, iirc it's also missing some tests.

@madadam
Copy link
Contributor

madadam commented Sep 15, 2022

@xfbs : I've rebased it already in my local temp branch: https://github.com/madadam/sqlx/commits/patches. Feel free to use it.

@billy1624
Copy link
Contributor

Any updates? :)

@abonander
Copy link
Collaborator

@xfbs I finally finished my massive refactor, do you mind rebasing one more time?

@xfbs
Copy link
Author

xfbs commented Feb 2, 2023 via email

@abonander
Copy link
Collaborator

Closing due to inactivity. Feel free to reopen if you get a chance to come back to this.

@abonander abonander closed this Mar 2, 2023
Copy link

@bonsairobo bonsairobo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome!

Comment on lines +42 to +44
/// Begin a new transaction or establish a savepoint within the active transaction.
///
/// Returns a [`Transaction`] for controlling and tracking the new transaction.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say something about options.

where
Self: Sized,
{
Self::begin_with(self, Default::default())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not take the same approach for the other impls (like impl Acquire for Pool)?

@@ -43,10 +55,14 @@ impl TransactionManager for MySqlTransactionManager {
fn rollback(conn: &mut MySqlConnection) -> BoxFuture<'_, Result<(), Error>> {
Box::pin(async move {
let depth = conn.transaction_depth;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this var?

@@ -62,13 +67,14 @@ impl<'c, DB> Transaction<'c, DB>
where
DB: Database,
{
pub(crate) fn begin(
pub(crate) fn begin_with(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep begin to break less user code.

}
}

/// Transaction behaviors for SQLite.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQLITE_TXN_NONE => SqliteTransactionState::None,
SQLITE_TXN_READ => SqliteTransactionState::Read,
SQLITE_TXN_WRITE => SqliteTransactionState::Write,
_ => return Err(Error::Protocol("Invalid transaction state".into())),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to format the value into the error message to make debugging easier.

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.

6 participants