File tree Expand file tree Collapse file tree 3 files changed +18
-9
lines changed
cardinal_pythonlib/sqlalchemy Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -104,10 +104,10 @@ def get_current_revision(
104104 version_table: table name for Alembic versions
105105 """
106106 engine = create_engine (database_url , future = True )
107- conn = engine .connect ()
108- opts = {"version_table" : version_table }
109- mig_context = MigrationContext .configure (conn , opts = opts )
110- return mig_context .get_current_revision ()
107+ with engine .connect () as conn :
108+ opts = {"version_table" : version_table }
109+ mig_context = MigrationContext .configure (conn , opts = opts )
110+ return mig_context .get_current_revision ()
111111
112112
113113def get_current_and_head_revision (
Original file line number Diff line number Diff line change @@ -307,12 +307,14 @@ def _attach_view(
307307 of "selectable") is created after the table is created, and dropped before
308308 the table is dropped, via listeners.
309309 """
310- t = table (tablename )
311-
312- # noinspection PyProtectedMember
313- t ._columns ._populate_separate_keys (
314- col ._make_proxy (t ) for col in selectable .selected_columns
310+ t = table (
311+ tablename ,
312+ * (
313+ Column (c .name , c .type , primary_key = c .primary_key )
314+ for c in selectable .selected_columns
315+ ),
315316 )
317+ t .primary_key .update (c for c in t .c if c .primary_key )
316318
317319 event .listen (
318320 metadata ,
Original file line number Diff line number Diff line change @@ -852,3 +852,10 @@ Quick links:
852852- Bugfix to ``cardinal_pythonlib.sqlalchemy.sqlserver `` functions as they
853853 were executing unconditionally, regardless of SQLAlchemy dialect (they should
854854 have been conditional to SQL Server).
855+
856+ **2.0.2 **
857+
858+ - Bugfix to
859+ :func: `cardinal_pythonlib.sqlalchemy.alembic_func.get_current_revision ` where
860+ since SQLAlchemy 2.0, the database connection was persisting, resulting in a
861+ metadata lock.
You can’t perform that action at this time.
0 commit comments