]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- [bug] Fixed support of schema-qualified
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 25 Apr 2012 15:10:42 +0000 (11:10 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 25 Apr 2012 15:10:42 +0000 (11:10 -0400)
  ForeignKey target in column alter operations,
  courtesy Alexander Kolov.

CHANGES
alembic/util.py
tests/test_op.py

diff --git a/CHANGES b/CHANGES
index 23523a0387230f928901346d70badafad5fe0cd2..0f980847c4ebe27086e5910b878c475e40521189 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,10 @@
 - [feature] Added support for UniqueConstraint
   in autogenerate, courtesy Atsushi Odagiri
 
+- [bug] Fixed support of schema-qualified 
+  ForeignKey target in column alter operations,
+  courtesy Alexander Kolov.
+
 0.3.1
 =====
 - [bug] bulk_insert() fixes:
index d5fa5a45856e139feb2acbfae37fb8b2fe501e3c..fb0c51a51ef727d2737ab4fbd7c51c6dc47d55b8 100644 (file)
@@ -18,7 +18,12 @@ class CommandError(Exception):
     pass
 
 from sqlalchemy import __version__
-_vers = tuple([int(x) for x in __version__.split(".")])
+def _safe_int(value):
+    try:
+        return int(value)
+    except:
+        return 0
+_vers = tuple([_safe_int(x) for x in __version__.split(".")])
 sqla_06 = _vers > (0, 6)
 sqla_07 = _vers > (0, 7)
 if not sqla_06:
index 2d6a29b1218b5d5bf78baf5c2cfcc2e910dba328..71d78d95db544500a2627505508e353b7465aa25 100644 (file)
@@ -62,6 +62,14 @@ def test_add_column_fk_self_referential():
         "ALTER TABLE t1 ADD FOREIGN KEY(c1) REFERENCES t1 (c2)"
     )
 
+def test_add_column_fk_schema():
+    context = op_fixture()
+    op.add_column('t1', Column('c1', Integer, ForeignKey('remote.t2.c2'), nullable=False))
+    context.assert_(
+    'ALTER TABLE t1 ADD COLUMN c1 INTEGER NOT NULL', 
+    'ALTER TABLE t1 ADD FOREIGN KEY(c1) REFERENCES remote.t2 (c2)'
+    )
+
 def test_drop_column():
     context = op_fixture()
     op.drop_column('t1', 'c1')