referent_schema=None, initially=None,
match=None, **dialect_kw):
m = self.metadata()
- if source == referent:
+ if source == referent and source_schema == referent_schema:
t1_cols = local_cols + remote_cols
else:
t1_cols = local_cols
:version: 0.8.11
:released:
+ .. change:: fk_schema_compare
+ :tags: bug, operations
+
+ Fixed bug in :func:`.ops.create_foreign_key` where the internal table
+ representation would not be created properly if the foriegn key referred
+ to a table in a different schema of the same name. Pull request
+ courtesy Konstantin Lebedev.
+
.. changelog::
:version: 0.8.10
:released: January 17, 2017
"REFERENCES bar2.t2 (bat, hoho)"
)
+ def test_add_foreign_key_schema_same_tablename(self):
+ context = op_fixture()
+ op.create_foreign_key('fk_test', 't1', 't1',
+ ['foo', 'bar'], ['bat', 'hoho'],
+ source_schema='foo2', referent_schema='bar2')
+ context.assert_(
+ "ALTER TABLE foo2.t1 ADD CONSTRAINT fk_test FOREIGN KEY(foo, bar) "
+ "REFERENCES bar2.t1 (bat, hoho)"
+ )
+
def test_add_foreign_key_onupdate(self):
context = op_fixture()
op.create_foreign_key('fk_test', 't1', 't2',