diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-03 17:03:15 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-03 17:04:03 -0400 |
| commit | 1fc2611e20ce94d3bbefc6910ba1127c400195b5 (patch) | |
| tree | 57160c0be9c8f920f62bcb6807d78cd1a0f9b279 /test/sql/test_metadata.py | |
| parent | f38e2aa46064f4a29600c3871758d63f3fa87595 (diff) | |
| download | sqlalchemy-1fc2611e20ce94d3bbefc6910ba1127c400195b5.tar.gz | |
Fixed bug whereby joining a select() of a table "A" with multiple
foreign key paths to a table "B", to that table "B", would fail
to produce the "ambiguous join condition" error that would be
reported if you join table "A" directly to "B"; it would instead
produce a join condition with multiple criteria.
[ticket:2738]
Conflicts:
doc/build/changelog/changelog_09.rst
Diffstat (limited to 'test/sql/test_metadata.py')
| -rw-r--r-- | test/sql/test_metadata.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index db2eaa4fa..fbdd06565 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -1211,6 +1211,30 @@ class ConstraintTest(fixtures.TestBase): schema.CreateTable(t1).compile ) + def test_constraint_copied_to_proxy_ok(self): + m = MetaData() + t1 = Table('t1', m, Column('id', Integer, primary_key=True)) + t2 = Table('t2', m, Column('id', Integer, ForeignKey('t1.id'), + primary_key=True)) + + s = tsa.select([t2]) + t2fk = list(t2.c.id.foreign_keys)[0] + sfk = list(s.c.id.foreign_keys)[0] + + # the two FKs share the ForeignKeyConstraint + is_( + t2fk.constraint, + sfk.constraint + ) + + # but the ForeignKeyConstraint isn't + # aware of the select's FK + eq_( + t2fk.constraint.elements, + [t2fk] + ) + + class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase): """Test Column() construction.""" |
