listenbrainz-server icon indicating copy to clipboard operation
listenbrainz-server copied to clipboard

Remove reliance on implicit autocommit

Open amCap1712 opened this issue 2 years ago • 0 comments

This PR is the first in a series of PRs to prepare the codebase for upgrading to SQLAlchemy 2.0. The 2.0 version isn't out yet but we can use the future flag in version 1.4 to use the newer API. Some of these API changes are useful when migrating to transactional tests.

This PR enables the SQLAlchemy Deprecation warnings in tests and fixes one type of those warnings:

The current statement is being autocommitted using implicit autocommit, which will be removed in SQLAlchemy 2.0. Use the .begin() method of Engine or Connection in order to use an explicit transaction for DML and DDL statements.

(Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)

For rationale, see section: https://docs.sqlalchemy.org/en/14/changelog/migration_20.html#library-level-but-not-driver-level-autocommit-removed-from-both-core-and-orm

amCap1712 avatar Aug 24 '22 10:08 amCap1712