]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Non-working "schema" argument on :class:`.ForeignKey` is deprecated;
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 8 Oct 2013 23:25:28 +0000 (19:25 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 8 Oct 2013 23:25:28 +0000 (19:25 -0400)
raises a warning.  Removed in 0.9. [ticket:2831]

doc/build/changelog/changelog_08.rst
lib/sqlalchemy/schema.py
test/sql/test_metadata.py

index 0cfeedf8d8c6fee3ccae8d77bd9bc71cfeb40670..54e10ec64aeabc4fdc1120c3e62f638777b4aaf8 100644 (file)
 .. changelog::
     :version: 0.8.3
 
+    .. change::
+        :tags: bug, sql
+        :tickets: 2831
+
+        Non-working "schema" argument on :class:`.ForeignKey` is deprecated;
+        raises a warning.  Removed in 0.9.
+
     .. change::
         :tags: bug, postgresql
         :tickets: 2819
index 863c756bd8fb39b6655bedc2199e40862899a5e0..641650d32afeca9156a6890cad38dbead5366e47 100644 (file)
@@ -1300,6 +1300,8 @@ class ForeignKey(SchemaItem):
             DDL for this constraint. Typical values include SIMPLE, PARTIAL
             and FULL.
 
+        :param schema: Deprecated; this flag does nothing and will be removed
+            in 0.9.
         """
 
         self._colspec = column
@@ -1320,6 +1322,12 @@ class ForeignKey(SchemaItem):
         self.link_to_name = link_to_name
         self.match = match
 
+        if schema:
+            util.warn_deprecated(
+                "'schema' argument on ForeignKey has no effect - "
+                "please specify the target as "
+                "<schemaname>.<tablename>.<colname>.")
+
     def __repr__(self):
         return "ForeignKey(%r)" % self._get_colspec()
 
index fbdd06565a172214d04c9a74cf3b8dbb62fd42c0..3075d3685cf836e90c40abb4bdac4535a0047ac4 100644 (file)
@@ -212,6 +212,13 @@ class MetaDataTest(fixtures.TestBase, ComparesTables):
         assert b.c.a_id.references(a.c.id)
         eq_(len(b.constraints), 2)
 
+    def test_fk_erroneous_schema_arg(self):
+        assert_raises_message(
+            exc.SADeprecationWarning,
+            "'schema' argument on ForeignKey has no effect.",
+            ForeignKey, "foo.bar", schema='myschema'
+        )
+
     def test_fk_construct(self):
         c1 = Column('foo', Integer)
         c2 = Column('bar', Integer)