]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Remove typo in _exec_drop_col_fk_constraint
authorOleg Shigorin <mail@olegshigor.in>
Fri, 24 Jul 2020 13:18:18 +0000 (09:18 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 25 Jul 2020 20:19:49 +0000 (16:19 -0400)
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

alembic/ddl/mssql.py
docs/build/unreleased/716.rst [new file with mode: 0644]
tests/test_mssql.py

index 78a7eb65e1f05154b06070eaafa4c95fa3b55abe..e20e069ddd8fb3f6281bc32ac05f45f70a4d5783 100644 (file)
@@ -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 (file)
index 0000000..dd490ed
--- /dev/null
@@ -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.
index 3aab4c13ac21d21bc9391c671627736510aea9c7..56aafc4a34eab351bcae631f1d0e0b180ecad120 100644 (file)
@@ -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)"
         )