MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_retain_table_schema

Method test_retain_table_schema

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

Source from the content-addressed store, hash-verified

1244 )
1245
1246 def test_retain_table_schema(self):
1247 meta = MetaData()
1248
1249 table = Table(
1250 "mytable",
1251 meta,
1252 Column("myid", Integer, primary_key=True),
1253 Column("name", String(40), nullable=True),
1254 Column(
1255 "description", String(30), CheckConstraint("description='hi'")
1256 ),
1257 UniqueConstraint("name"),
1258 schema="myschema",
1259 )
1260
1261 table2 = Table(
1262 "othertable",
1263 meta,
1264 Column("id", Integer, primary_key=True),
1265 Column("myid", Integer, ForeignKey("myschema.mytable.myid")),
1266 schema="myschema",
1267 )
1268
1269 meta2 = MetaData()
1270 table_c = table.to_metadata(meta2)
1271 table2_c = table2.to_metadata(meta2)
1272
1273 eq_(
1274 str(table_c.join(table2_c).onclause),
1275 str(table_c.c.myid == table2_c.c.myid),
1276 )
1277 eq_(
1278 str(table_c.join(table2_c).onclause),
1279 "myschema.mytable.myid = myschema.othertable.myid",
1280 )
1281
1282 def test_change_name_retain_metadata(self):
1283 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