From 799689d26eb6b8eb84154c758c6818466e2e9f12 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Wed, 27 Sep 2023 14:29:03 +1000 Subject: [PATCH] trying something that I *think* should be throwing warnings for sql 2.0 issues, not sure it works? --- main.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/main.py b/main.py index 2953dad..85cc628 100644 --- a/main.py +++ b/main.py @@ -18,6 +18,28 @@ from flask_ldap3_login import LDAP3LoginManager from flask_login import LoginManager, login_user, login_required, UserMixin, current_user, logout_user from flask_ldap3_login.forms import LDAPLoginForm +# DEAL WITH MIGRATION TO SQLALCHEMY 2.0 +import warnings +from sqlalchemy import exc + +# for warnings not included in regex-based filter below, just log +warnings.filterwarnings("always", category=exc.Base20DeprecationWarning) + +# for warnings related to execute() / scalar(), raise +for msg in [ + r"The (?:Executable|Engine)\.(?:execute|scalar)\(\) function", + r"The current statement is being autocommitted using implicit autocommit,", + r"The connection.execute\(\) method in SQLAlchemy 2.0 will accept " + "parameters as a single dictionary or a single sequence of " + "dictionaries only.", + r"The Connection.connect\(\) function/method is considered legacy", + r".*DefaultGenerator.execute\(\)", +]: + warnings.filterwarnings( + "error", + message=msg, + category=exc.Base20DeprecationWarning, + ) # pylint: disable=no-member