Skip to content

Commit d544698

Browse files
committed
Remove use of autocommit
Change-Id: I6e973935edf5e754ba054e724b6963b6d5fd795a
1 parent a41c884 commit d544698

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

magnum/db/sqlalchemy/api.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@
4747
def _create_facade_lazily():
4848
global _FACADE
4949
if _FACADE is None:
50-
# FIXME(karolinku): autocommit=True it's not compatible with
51-
# SQLAlchemy 2.0, and will be removed in future
52-
_FACADE = db_session.EngineFacade.from_config(CONF, autocommit=True)
50+
_FACADE = db_session.EngineFacade.from_config(CONF)
5351
if profiler_sqlalchemy:
5452
if CONF.profiler.enabled and CONF.profiler.trace_sqlalchemy:
5553
profiler_sqlalchemy.add_tracing(sa, _FACADE.get_engine(), "db")

magnum/db/sqlalchemy/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ def save(self, session=None):
9393
if session is None:
9494
session = db_api.get_session()
9595

96-
super(MagnumBase, self).save(session)
96+
with session.begin():
97+
super(MagnumBase, self).save(session)
9798

9899

99100
Base = declarative_base(cls=MagnumBase)

0 commit comments

Comments
 (0)