Fixup get transaction#66
Closed
tdamsma wants to merge 5 commits into
Closed
Conversation
icemac
requested changes
May 4, 2021
Member
icemac
left a comment
There was a problem hiding this comment.
Generally it looks good to me.
Additionally a change log entry referencing the PR would be helpful.
Contributor
Author
Would this be version 1.5.0 or 1.4.1, as it is a fix of 1.4.0? |
Member
I think 1.4.1 would be fine as it is a bugfix. |
This was referenced Jun 29, 2021
Merged
Member
|
Is there still something which prevents us from merging this PR? |
Member
|
Thank you for this PR, it was included in #68 and is not in the 1.5 release of this package. Hopefully the change log entry I wrote meets the intention of this PR. |
Contributor
Author
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.
I just realized I made a mistake in #62, checking forget_transactionon the transation instead of the session. Luckily SQLALchemy 1.4 is still backwards compatible, so that is why it didn't fail in the tests and shouldn't have any consequences for the moment.And upon closer inspection,
session.transaction(that is deprecated in 1.4+) returns the current (possibly nested) transaction and starts a new one if there is none. SQLALchemy 1.4+ makes a distinction between gettingI added explicit checks for SQLALchemy >= 1.4.0 instead of hasattr/getattr, and made the distinction between nested and root transaction more explicit.
Not sure why I need to call
root_transaction = session.get_transaction() or session.begin()and not justroot_transaction = session.begin()as it seems to me that that should be equivalent; It seems to me thatbegin()should return the current root transaction if there is one but apparently this is not the case.