diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-07-08 21:18:46 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-07-08 21:18:46 +0000 |
commit | af611b101842ee9482ddd901762fd73a6fe62364 (patch) | |
tree | fba3ae06613124b86f51527b5fabd0d70fc3210f /test/dialect/postgres.py | |
parent | b9a59f5cefe4db59867a7484d03341571b1e3a4c (diff) | |
download | sqlalchemy-af611b101842ee9482ddd901762fd73a6fe62364.tar.gz |
- ForeignKey to a table in a schema thats not the default schema
requires the schema to be explicit; i.e. ForeignKey('alt_schema.users.id')
- the fix in "schema" above fixes postgres reflection of foreign keys from an
alt-schema table to a public schema table
Diffstat (limited to 'test/dialect/postgres.py')
-rw-r--r-- | test/dialect/postgres.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/dialect/postgres.py b/test/dialect/postgres.py index 8a69f2453..8d62625c9 100644 --- a/test/dialect/postgres.py +++ b/test/dialect/postgres.py @@ -121,6 +121,50 @@ class MiscTest(AssertMixin): meta1.drop_all() @testbase.supported('postgres') + def test_schema_reflection_2(self): + meta1 = MetaData(testbase.db) + subject = Table("subject", meta1, + Column("id", Integer, primary_key=True), + ) + + referer = Table("referer", meta1, + Column("id", Integer, primary_key=True), + Column("ref", Integer, ForeignKey('subject.id')), + schema="alt_schema") + meta1.create_all() + try: + meta2 = MetaData(testbase.db) + subject = Table("subject", meta2, autoload=True) + referer = Table("referer", meta2, schema="alt_schema", autoload=True) + print str(subject.join(referer).onclause) + self.assert_((subject.c.id==referer.c.ref).compare(subject.join(referer).onclause)) + finally: + meta1.drop_all() + + @testbase.supported('postgres') + def test_schema_reflection_3(self): + meta1 = MetaData(testbase.db) + subject = Table("subject", meta1, + Column("id", Integer, primary_key=True), + schema='alt_schema_2' + ) + + referer = Table("referer", meta1, + Column("id", Integer, primary_key=True), + Column("ref", Integer, ForeignKey('alt_schema_2.subject.id')), + schema="alt_schema") + + meta1.create_all() + try: + meta2 = MetaData(testbase.db) + subject = Table("subject", meta2, autoload=True, schema="alt_schema_2") + referer = Table("referer", meta2, schema="alt_schema", autoload=True) + print str(subject.join(referer).onclause) + self.assert_((subject.c.id==referer.c.ref).compare(subject.join(referer).onclause)) + finally: + meta1.drop_all() + + @testbase.supported('postgres') def test_preexecute_passivedefault(self): """test that when we get a primary key column back from reflecting a table which has a default value on it, we pre-execute |