MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_retain_table_schema

Method test_retain_table_schema

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

Source from the content-addressed store, hash-verified

1179 )
1180
1181 def test_retain_table_schema(self):
1182 meta = MetaData()
1183
1184 table = Table(
1185 "mytable",
1186 meta,
1187 Column("myid", Integer, primary_key=True),
1188 Column("name", String(40), nullable=True),
1189 Column(
1190 "description", String(30), CheckConstraint("description='hi'")
1191 ),
1192 UniqueConstraint("name"),
1193 schema="myschema",
1194 )
1195
1196 table2 = Table(
1197 "othertable",
1198 meta,
1199 Column("id", Integer, primary_key=True),
1200 Column("myid", Integer, ForeignKey("myschema.mytable.myid")),
1201 schema="myschema",
1202 )
1203
1204 meta2 = MetaData()
1205 table_c = table.to_metadata(meta2)
1206 table2_c = table2.to_metadata(meta2)
1207
1208 eq_(
1209 str(table_c.join(table2_c).onclause),
1210 str(table_c.c.myid == table2_c.c.myid),
1211 )
1212 eq_(
1213 str(table_c.join(table2_c).onclause),
1214 "myschema.mytable.myid = myschema.othertable.myid",
1215 )
1216
1217 def test_change_name_retain_metadata(self):
1218 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