diff options
author | Michael Trier <mtrier@gmail.com> | 2010-02-25 06:34:37 +0000 |
---|---|---|
committer | Michael Trier <mtrier@gmail.com> | 2010-02-25 06:34:37 +0000 |
commit | e759031b16520a1389cd705c7a6c15cc894b226d (patch) | |
tree | a6a32abdd7ef3d698376cad9adfa925d583cdc14 /test | |
parent | 5b5e2df00b782ac59500f0759b64d5c07d2e9d16 (diff) | |
download | sqlalchemy-e759031b16520a1389cd705c7a6c15cc894b226d.tar.gz |
Added the ability to strip the schema when using tometadata by passing schema=None as an argument. Fixes #1673.
Diffstat (limited to 'test')
-rw-r--r-- | test/engine/test_metadata.py | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/test/engine/test_metadata.py b/test/engine/test_metadata.py index 50109e15a..0d2cb7775 100644 --- a/test/engine/test_metadata.py +++ b/test/engine/test_metadata.py @@ -203,8 +203,57 @@ class MetaDataTest(TestBase, ComparesTables): eq_(str(table_c.join(table2_c).onclause), str(table_c.c.myid == table2_c.c.myid)) eq_(str(table_c.join(table2_c).onclause), "someschema.mytable.myid = someschema.othertable.myid") - - + + def test_tometadata_default_schema(self): + meta = MetaData() + + table = Table('mytable', meta, + Column('myid', Integer, primary_key=True), + Column('name', String(40), nullable=True), + Column('description', String(30), CheckConstraint("description='hi'")), + UniqueConstraint('name'), + test_needs_fk=True, + schema='myschema', + ) + + table2 = Table('othertable', meta, + Column('id', Integer, primary_key=True), + Column('myid', Integer, ForeignKey('myschema.mytable.myid')), + test_needs_fk=True, + schema='myschema', + ) + + meta2 = MetaData() + table_c = table.tometadata(meta2) + table2_c = table2.tometadata(meta2) + + eq_(str(table_c.join(table2_c).onclause), str(table_c.c.myid == table2_c.c.myid)) + eq_(str(table_c.join(table2_c).onclause), "myschema.mytable.myid = myschema.othertable.myid") + + def test_tometadata_strip_schema(self): + meta = MetaData() + + table = Table('mytable', meta, + Column('myid', Integer, primary_key=True), + Column('name', String(40), nullable=True), + Column('description', String(30), CheckConstraint("description='hi'")), + UniqueConstraint('name'), + test_needs_fk=True, + ) + + table2 = Table('othertable', meta, + Column('id', Integer, primary_key=True), + Column('myid', Integer, ForeignKey('mytable.myid')), + test_needs_fk=True, + ) + + meta2 = MetaData() + table_c = table.tometadata(meta2, schema=None) + table2_c = table2.tometadata(meta2, schema=None) + + eq_(str(table_c.join(table2_c).onclause), str(table_c.c.myid == table2_c.c.myid)) + eq_(str(table_c.join(table2_c).onclause), "mytable.myid = othertable.myid") + def test_nonexistent(self): assert_raises(tsa.exc.NoSuchTableError, Table, 'fake_table', |