diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-12 17:14:34 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-12 17:14:34 -0500 |
| commit | 345de2ee1dfb12c6314144c2b7ed6fb4a7a3cb7c (patch) | |
| tree | 4540d2c510e215123f5cbdb724bd34f889fa6673 /test/engine/test_reflection.py | |
| parent | ba0fb069d5e76e4fe3365765caa1239bfd7371cc (diff) | |
| download | sqlalchemy-345de2ee1dfb12c6314144c2b7ed6fb4a7a3cb7c.tar.gz | |
- [bug] Fixed bug in new "autoload_replace" flag
which would fail to preserve the primary
key constraint of the reflected table.
[ticket:2402]
Diffstat (limited to 'test/engine/test_reflection.py')
| -rw-r--r-- | test/engine/test_reflection.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py index 13c8ee0ef..f385a0fa2 100644 --- a/test/engine/test_reflection.py +++ b/test/engine/test_reflection.py @@ -203,7 +203,7 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): assert len(t2.indexes) == 2 @testing.provide_metadata - def test_autoload_replace(self): + def test_autoload_replace_foreign_key(self): a = Table('a', self.metadata, Column('id', Integer, primary_key=True)) b = Table('b', self.metadata, Column('id', Integer, primary_key=True), Column('a_id', Integer)) @@ -220,6 +220,18 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): assert b2.c.a_id.references(a2.c.id) eq_(len(b2.constraints), 2) + @testing.provide_metadata + def test_autoload_replace_primary_key(self): + a = Table('a', self.metadata, Column('id', Integer)) + self.metadata.create_all() + + m2 = MetaData() + a2 = Table('a', m2, Column('id', Integer, primary_key=True)) + + Table('a', m2, autoload=True, autoload_with=testing.db, + autoload_replace=False, extend_existing=True) + eq_(list(a2.primary_key), [a2.c.id]) + def test_autoload_replace_arg(self): Table('t', MetaData(), autoload_replace=False) |
