diff options
Diffstat (limited to 'test/sql/test_selectable.py')
-rw-r--r-- | test/sql/test_selectable.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 94e4ac024..95a0336b7 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -916,6 +916,44 @@ class RefreshForNewColTest(fixtures.TestBase): j._refresh_for_new_column(q) assert j.c.b_q is q + def test_fk_table(self): + m = MetaData() + fk = ForeignKey('x.id') + Table('x', m, Column('id', Integer)) + a = Table('a', m, Column('x', Integer, fk)) + a.c + + q = Column('q', Integer) + a.append_column(q) + a._refresh_for_new_column(q) + eq_(a.foreign_keys, set([fk])) + + fk2 = ForeignKey('g.id') + p = Column('p', Integer, fk2) + a.append_column(p) + a._refresh_for_new_column(p) + eq_(a.foreign_keys, set([fk, fk2])) + + def test_fk_join(self): + m = MetaData() + fk = ForeignKey('x.id') + Table('x', m, Column('id', Integer)) + a = Table('a', m, Column('x', Integer, fk)) + b = Table('b', m, Column('y', Integer)) + j = a.join(b, a.c.x == b.c.y) + j.c + + q = Column('q', Integer) + b.append_column(q) + j._refresh_for_new_column(q) + eq_(j.foreign_keys, set([fk])) + + fk2 = ForeignKey('g.id') + p = Column('p', Integer, fk2) + b.append_column(p) + j._refresh_for_new_column(p) + eq_(j.foreign_keys, set([fk, fk2])) + class AnonLabelTest(fixtures.TestBase): |