MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_reserved

Method test_reserved

test/engine/test_reflection.py:1171–1212  ·  view source on GitHub ↗
(self, connection, metadata)

Source from the content-addressed store, hash-verified

1169 @testing.crashes("oracle", "FIXME: unknown, confirm not fails_on")
1170 @testing.requires.check_constraints
1171 def test_reserved(self, connection, metadata):
1172 # check a table that uses a SQL reserved name doesn't cause an
1173 # error
1174
1175 meta = metadata
1176 table_a = Table(
1177 "select",
1178 meta,
1179 Column("not", sa.Integer, primary_key=True),
1180 Column("from", sa.String(12), nullable=False),
1181 sa.UniqueConstraint("from", name="when"),
1182 )
1183 sa.Index("where", table_a.c["from"])
1184
1185 if connection.dialect.requires_name_normalize:
1186 check_col = "TRUE"
1187 else:
1188 check_col = "true"
1189 quoter = connection.dialect.identifier_preparer.quote_identifier
1190
1191 Table(
1192 "false",
1193 meta,
1194 Column("create", sa.Integer, primary_key=True),
1195 Column("true", sa.Integer, sa.ForeignKey("select.not")),
1196 sa.CheckConstraint("%s <> 1" % quoter(check_col), name="limit"),
1197 )
1198
1199 table_c = Table(
1200 "is",
1201 meta,
1202 Column("or", sa.Integer, nullable=False, primary_key=True),
1203 Column("join", sa.Integer, nullable=False, primary_key=True),
1204 sa.PrimaryKeyConstraint("or", "join", name="to"),
1205 )
1206 index_c = sa.Index("else", table_c.c.join)
1207 meta.create_all(connection)
1208 index_c.drop(connection)
1209 meta2 = MetaData()
1210 Table("select", meta2, autoload_with=connection)
1211 Table("false", meta2, autoload_with=connection)
1212 Table("is", meta2, autoload_with=connection)
1213
1214 def test_reflect_all(self, connection, metadata):
1215 names = ["rt_%s" % name for name in ("a", "b", "c", "d", "e")]

Callers

nothing calls this directly

Calls 5

dropMethod · 0.95
TableClass · 0.90
ColumnClass · 0.90
MetaDataClass · 0.90
create_allMethod · 0.80

Tested by

no test coverage detected