]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed "table" argument on constructor of ForeginKeyConstraint
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 26 Apr 2010 04:14:21 +0000 (00:14 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 26 Apr 2010 04:14:21 +0000 (00:14 -0400)
[ticket:1571]

CHANGES
lib/sqlalchemy/schema.py
test/engine/test_metadata.py

diff --git a/CHANGES b/CHANGES
index d7e7b3dfc3b1b606c4060032ed92356b3ef8c8e1..2ae0415a935cab55a12f840a6c0f61e2ef419a19 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,9 @@ CHANGES
   
   - Fixed errant space character when generating ADD CONSTRAINT
     for a named UNIQUE constraint.
+
+  - Fixed "table" argument on constructor of ForeginKeyConstraint
+    [ticket:1571]
     
 - oracle
   - Added a check for cx_oracle versions lower than version 5,
index 4e4468a850c0b1aea40b6c130315e11b5822d802..7a12891804c56e4ce032b7ef5582835857bec904 100644 (file)
@@ -1568,7 +1568,7 @@ class ForeignKeyConstraint(Constraint):
                     link_to_name=self.link_to_name
                 )
 
-        if table:
+        if table is not None:
             self._set_parent(table)
     
     @property
index 3a1a19cd4affdc164094066bacfc54628f886030..41b744d9bb9a1c04ea4130717a5bfa27c6a8a2e3 100644 (file)
@@ -106,7 +106,14 @@ class MetaDataTest(TestBase, ComparesTables):
         for k in kw:
             eq_(getattr(fk1c, k), kw[k])
             eq_(getattr(fk2c, k), kw[k])
-        
+    
+    def test_fk_construct(self):
+        c1 = Column('foo', Integer)
+        c2 = Column('bar', Integer)
+        m = MetaData()
+        t1 = Table('t', m, c1, c2)
+        fk1 = ForeignKeyConstraint(('foo', ), ('bar', ), table=t1)
+        assert fk1 in t1.constraints
         
     @testing.exclude('mysql', '<', (4, 1, 1), 'early types are squirrely')
     def test_to_metadata(self):