From: Oleg Shigorin Date: Fri, 24 Jul 2020 13:18:18 +0000 (-0400) Subject: Remove typo in _exec_drop_col_fk_constraint X-Git-Tag: rel_1_4_3~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9ba30ace0a33079b64dc75c7e8ccc3b70139beb;p=thirdparty%2Fsqlalchemy%2Falembic.git Remove typo in _exec_drop_col_fk_constraint Fixed issue where the ``mssql_drop_foreign_key=True`` flag on ``op.drop_column`` would lead to incorrect syntax error due to a typo in the SQL emitted, same typo was present in the test as well so it was not detected. Pull request courtesy Oleg Shigorin. Fixes: #716 Closes: #717 Pull-request: https://github.com/sqlalchemy/alembic/pull/717 Pull-request-sha: dcd90fb4dfe8acd63670aedbdee58be25d4781d2 Change-Id: I022a66a3bcebf689945cfbd36bed0ebed248364f --- diff --git a/alembic/ddl/mssql.py b/alembic/ddl/mssql.py index 78a7eb65..e20e069d 100644 --- a/alembic/ddl/mssql.py +++ b/alembic/ddl/mssql.py @@ -205,7 +205,7 @@ select @const_name = [name] from sys.foreign_keys fk join sys.foreign_key_columns fkc on fk.object_id=fkc.constraint_object_id where fkc.parent_object_id = object_id('%(schema_dot)s%(tname)s') -`and col_name(fkc.parent_object_id, fkc.parent_column_id) = '%(colname)s' +and col_name(fkc.parent_object_id, fkc.parent_column_id) = '%(colname)s' exec('alter table %(tname_quoted)s drop constraint ' + @const_name)""" % { "tname": tname, "colname": colname, diff --git a/docs/build/unreleased/716.rst b/docs/build/unreleased/716.rst new file mode 100644 index 00000000..dd490edf --- /dev/null +++ b/docs/build/unreleased/716.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: bug, mssql + :tickets: 716 + + Fixed issue where the ``mssql_drop_foreign_key=True`` flag on + ``op.drop_column`` would lead to incorrect syntax error due to a typo in the + SQL emitted, same typo was present in the test as well so it was not + detected. Pull request courtesy Oleg Shigorin. diff --git a/tests/test_mssql.py b/tests/test_mssql.py index 3aab4c13..56aafc4a 100644 --- a/tests/test_mssql.py +++ b/tests/test_mssql.py @@ -191,7 +191,7 @@ class OpTest(TestBase): "select @const_name = [name] from\n" "sys.foreign_keys fk join sys.foreign_key_columns fkcon " "fk.object_id=fkc.constraint_object_id\n" - "where fkc.parent_object_id = object_id('t1')`and " + "where fkc.parent_object_id = object_id('t1')\nand " "col_name(fkc.parent_object_id, fkc.parent_column_id) = 'c1'\n" "exec('alter table t1 drop constraint ' + @const_name)" ) @@ -208,7 +208,7 @@ class OpTest(TestBase): "select @const_name = [name] from\n" "sys.foreign_keys fk join sys.foreign_key_columns fkcon " "fk.object_id=fkc.constraint_object_id\n" - "where fkc.parent_object_id = object_id('xyz.t1')`and " + "where fkc.parent_object_id = object_id('xyz.t1')\nand " "col_name(fkc.parent_object_id, fkc.parent_column_id) = 'c1'\n" "exec('alter table xyz.t1 drop constraint ' + @const_name)" )