MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_create_table

Method test_create_table

test/engine/test_execute.py:1183–1213  ·  view source on GitHub ↗
(self, plain_tables, connection)

Source from the content-addressed store, hash-verified

1181 return ts1, tsnone
1182
1183 def test_create_table(self, plain_tables, connection):
1184 map_ = {
1185 None: config.test_schema,
1186 "foo": config.test_schema,
1187 "bar": None,
1188 }
1189
1190 metadata = MetaData()
1191 t1 = Table("t1", metadata, Column("x", Integer))
1192 t2 = Table("t2", metadata, Column("x", Integer), schema="foo")
1193 t3 = Table("t3", metadata, Column("x", Integer), schema="bar")
1194
1195 with self.sql_execution_asserter(connection) as asserter:
1196 conn = connection.execution_options(schema_translate_map=map_)
1197
1198 t1.create(conn)
1199 t2.create(conn)
1200 t3.create(conn)
1201
1202 t3.drop(conn)
1203 t2.drop(conn)
1204 t1.drop(conn)
1205
1206 asserter.assert_(
1207 CompiledSQL("CREATE TABLE __[SCHEMA__none].t1 (x INTEGER)"),
1208 CompiledSQL("CREATE TABLE __[SCHEMA_foo].t2 (x INTEGER)"),
1209 CompiledSQL("CREATE TABLE __[SCHEMA_bar].t3 (x INTEGER)"),
1210 CompiledSQL("DROP TABLE __[SCHEMA_bar].t3"),
1211 CompiledSQL("DROP TABLE __[SCHEMA_foo].t2"),
1212 CompiledSQL("DROP TABLE __[SCHEMA__none].t1"),
1213 )
1214
1215 def test_ddl_hastable(self, plain_tables, connection):
1216 map_ = {

Callers

nothing calls this directly

Calls 9

createMethod · 0.95
dropMethod · 0.95
MetaDataClass · 0.90
TableClass · 0.90
ColumnClass · 0.90
CompiledSQLClass · 0.90
execution_optionsMethod · 0.45
assert_Method · 0.45

Tested by

no test coverage detected