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

Sqlalchemy backend should create a transaction if it is going to call session.commit #115

Open
daack93 opened this issue Apr 29, 2019 · 0 comments

Comments

@daack93
Copy link

daack93 commented Apr 29, 2019

See
https://docs.sqlalchemy.org/en/13/orm/session_transaction.html
http://alextechrants.blogspot.com/2013/08/unit-testing-sqlalchemy-apps.html

L312 of https://github.com/klen/mixer/blob/develop/mixer/backend/sqlalchemy.py will end the session's current transaction and commit them.

This will break things that rely on nested sessions, such as the example above which use nested transaction to encapsulate tests. It seems like a good argument not to use nested transactions that way, but I think you should also try to avoid interfering with user transactions if possible.

Ie. I think you should either drop the session.commit() line, and let users interact with sessions how they want, or call session.begin_nested() before session.add, so that the commit will not effect parent transactions.

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

No branches or pull requests

1 participant