summaryrefslogtreecommitdiff
path: root/test/engine/test_reflection.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-08-08 17:50:44 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-08-08 17:50:44 -0400
commitbb5a85feca1a6ed1aa7d18a04c0dfff3afa306c1 (patch)
tree12d6f26d360310bfa8b718e0876eff8eedd42c11 /test/engine/test_reflection.py
parent0b9afe1412898ba31282e75d90ca4d728613ca2b (diff)
parentbb3be98d3bee4b2bcef791be022ddb2510b9cf9c (diff)
downloadsqlalchemy-bb5a85feca1a6ed1aa7d18a04c0dfff3afa306c1.tar.gz
merge tip
Diffstat (limited to 'test/engine/test_reflection.py')
-rw-r--r--test/engine/test_reflection.py42
1 files changed, 40 insertions, 2 deletions
diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py
index 1cbc9ab59..a82f1ec52 100644
--- a/test/engine/test_reflection.py
+++ b/test/engine/test_reflection.py
@@ -326,7 +326,44 @@ class ReflectionTest(TestBase, ComparesTables):
assert len(a4.constraints) == 2
finally:
meta.drop_all()
+
+ @testing.provide_metadata
+ def test_override_composite_fk(self):
+ """Test double-remove of composite foreign key, when replaced."""
+
+ a = Table('a',
+ metadata,
+ Column('x', sa.Integer, primary_key=True),
+ Column('y', sa.Integer, primary_key=True),
+ )
+
+ b = Table('b',
+ metadata,
+ Column('x', sa.Integer, primary_key=True),
+ Column('y', sa.Integer, primary_key=True),
+ sa.ForeignKeyConstraint(['x', 'y'], ['a.x', 'a.y'])
+ )
+
+ metadata.create_all()
+ meta2 = MetaData()
+
+ c1 = Column('x', sa.Integer, primary_key=True)
+ c2 = Column('y', sa.Integer, primary_key=True)
+ f1 = sa.ForeignKeyConstraint(['x', 'y'], ['a.x', 'a.y'])
+ b1 = Table('b',
+ meta2, c1, c2, f1,
+ autoload=True,
+ autoload_with=testing.db
+ )
+
+ assert b1.c.x is c1
+ assert b1.c.y is c2
+ assert f1 in b1.constraints
+ assert len(b1.constraints) == 2
+
+
+
def test_override_keys(self):
"""test that columns can be overridden with a 'key',
and that ForeignKey targeting during reflection still works."""
@@ -510,8 +547,9 @@ class ReflectionTest(TestBase, ComparesTables):
)
assert_raises_message(sa.exc.InvalidRequestError,
- "Could not find table 'pkgs' with which "
- "to generate a foreign key",
+ "Foreign key assocated with column 'slots.pkg_id' "
+ "could not find table 'pkgs' with which to generate "
+ "a foreign key to target column 'pkg_id'",
metadata.create_all)
def test_composite_pks(self):