MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_change_schema

Method test_change_schema

test/sql/test_metadata.py:1147–1179  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1145 )
1146
1147 def test_change_schema(self):
1148 meta = MetaData()
1149
1150 table = Table(
1151 "mytable",
1152 meta,
1153 Column("myid", Integer, primary_key=True),
1154 Column("name", String(40), nullable=True),
1155 Column(
1156 "description", String(30), CheckConstraint("description='hi'")
1157 ),
1158 UniqueConstraint("name"),
1159 )
1160
1161 table2 = Table(
1162 "othertable",
1163 meta,
1164 Column("id", Integer, primary_key=True),
1165 Column("myid", Integer, ForeignKey("mytable.myid")),
1166 )
1167
1168 meta2 = MetaData()
1169 table_c = table.to_metadata(meta2, schema="someschema")
1170 table2_c = table2.to_metadata(meta2, schema="someschema")
1171
1172 eq_(
1173 str(table_c.join(table2_c).onclause),
1174 str(table_c.c.myid == table2_c.c.myid),
1175 )
1176 eq_(
1177 str(table_c.join(table2_c).onclause),
1178 "someschema.mytable.myid = someschema.othertable.myid",
1179 )
1180
1181 def test_retain_table_schema(self):
1182 meta = MetaData()

Callers

nothing calls this directly

Calls 10

to_metadataMethod · 0.95
MetaDataClass · 0.90
TableClass · 0.90
ColumnClass · 0.90
StringClass · 0.90
CheckConstraintClass · 0.90
UniqueConstraintClass · 0.90
ForeignKeyClass · 0.90
eq_Function · 0.90
joinMethod · 0.45

Tested by

no test coverage detected