From ff194921603a29d7e4c49b44dc554ff9180580c0 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 26 Apr 2010 00:14:21 -0400 Subject: [PATCH] - Fixed "table" argument on constructor of ForeginKeyConstraint [ticket:1571] --- CHANGES | 3 +++ lib/sqlalchemy/schema.py | 2 +- test/engine/test_metadata.py | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index d7e7b3dfc3..2ae0415a93 100644 --- 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, diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 4e4468a850..7a12891804 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -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 diff --git a/test/engine/test_metadata.py b/test/engine/test_metadata.py index 3a1a19cd4a..41b744d9bb 100644 --- a/test/engine/test_metadata.py +++ b/test/engine/test_metadata.py @@ -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): -- 2.47.2