Repository navigation
fix(#121): handle join_txn_mode for version_session - #122
Conversation
Pull Request Test Coverage Report for Build 7457526996
💛 - Coveralls |
| self.reset() | ||
|
|
||
| def create_version_session(self, session): | ||
| return sa.orm.session.Session(bind=session.connection(), join_transaction_mode="rollback_only") |
There was a problem hiding this comment.
We would also have to handle sqla 1.4 here aswell.
current CI workflow seems to have a bug, where sqla-1.4 is not getting installed in poetry's env,
can you also fix that?, if the fix breaks other items in CI we can create a seperate issue for it.
There was a problem hiding this comment.
Tried fixing this by replacing:
pip install 'sqlalchemy${{ matrix.sqla }}'
with
poetry add "sqlalchemy${{ matrix.sqla }}"
it is breaking other tests
|
|
||
| if not self.version_session: | ||
| self.version_session = sa.orm.session.Session(bind=session.connection()) | ||
| self.version_session = self.create_version_session(session) |
There was a problem hiding this comment.
can you also add testcase for this behaviour.
1e6190a to
8bf639a
Compare
- SQLA 2.0 introduced new session param called `join_transaction_mode` which changes the behaviour of how existing transactions are handled - When using a Connection with an existing SAVEPOINT: `SQLA-1.4`: the Session would propagate both commit() and rollback() calls to the underlying transaction. `SQLA-2.0`: use join_transaction_mode=control_fully to replicate the same behaviour. - When using a Connection without an existing SAVEPOINT: `SQLA-1.4`: the Session would propagate only rollback() calls to the underlying transaction. `SQLA-2.0`: use join_transaction_mode=rollback_only to replicate the same behaviour. - use `rollback_only` mode while creation of version_session, as it is using an existing connection, and we are never doing a commit() on it.
| self.reset() | ||
|
|
||
| def create_version_session(self, session): | ||
| try: |
There was a problem hiding this comment.
Test seems to be working with rebased code,
can you add small note saying what happened here so if someone comes cold to this code and has no gitlens is not confused.
SQLA 2.0 introduced new session param called
join_transaction_modewhich changes the behaviour of how existing transactions are handledWhen using a Connection with an existing SAVEPOINT:
SQLA-1.4: the Session would propagate both commit() and rollback() calls to the underlying transaction.SQLA-2.0: use join_transaction_mode=control_fully to replicate the same behaviour.When using a Connection without an existing SAVEPOINT:
SQLA-1.4: the Session would propagate only rollback() calls to the underlying transaction.SQLA-2.0: use join_transaction_mode=rollback_only to replicate the same behaviour.use
rollback_onlymode while creation of version_session, as it is using an existing connection, and we are never doing a commit() on it.Documentation: join_transaction_mode