From 64c58a3cf8357624567eb6084c421e618fabcb40 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 10 Sep 2023 07:44:13 -0500 Subject: [PATCH] Optionally configure SQLAlchemy Session with `future=True` this avoids the need for setting `cascade_backrefs=False` everywhere https://docs.sqlalchemy.org/en/14/errors.html#error-s9r1 https://docs.sqlalchemy.org/en/14/orm/session_api.html#sqlalchemy.orm.Session.params.future --- tailbone/app.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tailbone/app.py b/tailbone/app.py index 4d4f435c..6f41a8de 100644 --- a/tailbone/app.py +++ b/tailbone/app.py @@ -70,6 +70,10 @@ def make_rattail_config(settings): if hasattr(rattail_config, 'tempmon_engine'): tailbone.db.TempmonSession.configure(bind=rattail_config.tempmon_engine) + # maybe set "future" behavior for SQLAlchemy + if rattail_config.getbool('rattail.db', 'sqlalchemy_future_mode', usedb=False): + tailbone.db.Session.configure(future=True) + # create session wrappers for each "extra" Trainwreck engine for key, engine in rattail_config.trainwreck_engines.items(): if key != 'default':