summaryrefslogtreecommitdiff
path: root/test/sql/test_metadata.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-06-03 17:03:15 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-06-03 17:03:15 -0400
commit8a865a4d1f7bf7d399a551ae1c3f93e668ccc8aa (patch)
treea5fc83a316ce76951380007dd1495754aab1dcaa /test/sql/test_metadata.py
parentec04620f1fe609881ed2ad4a3d5b2fe313f4efa4 (diff)
downloadsqlalchemy-8a865a4d1f7bf7d399a551ae1c3f93e668ccc8aa.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]
Diffstat (limited to 'test/sql/test_metadata.py')
-rw-r--r--test/sql/test_metadata.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py
index c0873862d..8f0280765 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."""