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

Method test_create_table

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

Source from the content-addressed store, hash-verified

1121 return ts1, tsnone
1122
1123 def test_create_table(self, plain_tables, connection):
1124 map_ = {
1125 None: config.test_schema,
1126 "foo": config.test_schema,
1127 "bar": None,
1128 }
1129
1130 metadata = MetaData()
1131 t1 = Table("t1", metadata, Column("x", Integer))
1132 t2 = Table("t2", metadata, Column("x", Integer), schema="foo")
1133 t3 = Table("t3", metadata, Column("x", Integer), schema="bar")
1134
1135 with self.sql_execution_asserter(connection) as asserter:
1136 conn = connection.execution_options(schema_translate_map=map_)
1137
1138 t1.create(conn)
1139 t2.create(conn)
1140 t3.create(conn)
1141
1142 t3.drop(conn)
1143 t2.drop(conn)
1144 t1.drop(conn)
1145
1146 asserter.assert_(
1147 CompiledSQL("CREATE TABLE __[SCHEMA__none].t1 (x INTEGER)"),
1148 CompiledSQL("CREATE TABLE __[SCHEMA_foo].t2 (x INTEGER)"),
1149 CompiledSQL("CREATE TABLE __[SCHEMA_bar].t3 (x INTEGER)"),
1150 CompiledSQL("DROP TABLE __[SCHEMA_bar].t3"),
1151 CompiledSQL("DROP TABLE __[SCHEMA_foo].t2"),
1152 CompiledSQL("DROP TABLE __[SCHEMA__none].t1"),
1153 )
1154
1155 def test_ddl_hastable(self, plain_tables, connection):
1156 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