File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
cardinal_pythonlib/sqlalchemy Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -417,8 +417,18 @@ def execute_ddl(
417417 if sql :
418418 ddl = DDL (sql )
419419 with engine .connect () as connection :
420- # DDL doesn't need a COMMIT.
421420 connection .execute (ddl )
421+ # DDL may need a commit for some dialects:
422+ #
423+ # Generic (but generic may not be useful)
424+ # https://stackoverflow.com/questions/730621/do-ddl-statements-always-give-you-an-implicit-commit-or-can-you-get-an-implicit
425+ # Oracle - autocommitted?
426+ # https://docs.oracle.com/cd/A97335_02/apps.102/a83723/keyprog6.htm
427+ # but not Postgres?
428+ # https://dba.stackexchange.com/questions/340916/why-must-i-commit-after-the-alter-table-ddl-to-make-changes-visible
429+ # and in SQL Server they are "batched" so not entirely autocommitted
430+ # https://www.mssqltips.com/sqlservertip/4591/ddl-commands-in-transactions-in-sql-server-versus-oracle/
431+ connection .commit ()
422432
423433
424434# =============================================================================
Original file line number Diff line number Diff line change @@ -880,3 +880,8 @@ Quick links:
880880
881881- Allow ``db_url `` parameter to
882882 ``cardinal_pythonlib.sqlalchemy.alembic_func.create_database_migration_numbered_style ``.
883+
884+ **2.0.4 **
885+
886+ - Fix :func: `cardinal_pythonlib.sqlalchemy.schema.execute_ddl ` so that it always
887+ commits. Not all dialects commit automatically.
You can’t perform that action at this time.
0 commit comments