MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_schema_translate_select

Method test_schema_translate_select

test/sql/test_compiler.py:7039–7079  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7037 )
7038
7039 def test_schema_translate_select(self):
7040 m = MetaData()
7041 table1 = Table(
7042 "mytable",
7043 m,
7044 Column("myid", Integer),
7045 Column("name", String),
7046 Column("description", String),
7047 )
7048 schema_translate_map = {"remote_owner": "foob", None: "bar"}
7049
7050 self.assert_compile(
7051 table1.select().where(table1.c.name == "hi"),
7052 "SELECT bar.mytable.myid, bar.mytable.name, "
7053 "bar.mytable.description FROM bar.mytable "
7054 "WHERE bar.mytable.name = :name_1",
7055 schema_translate_map=schema_translate_map,
7056 render_schema_translate=True,
7057 )
7058
7059 self.assert_compile(
7060 table4.select().where(table4.c.value == "hi"),
7061 "SELECT foob.remotetable.rem_id, foob.remotetable.datatype_id, "
7062 "foob.remotetable.value FROM foob.remotetable "
7063 "WHERE foob.remotetable.value = :value_1",
7064 schema_translate_map=schema_translate_map,
7065 render_schema_translate=True,
7066 )
7067
7068 schema_translate_map = {"remote_owner": "foob"}
7069 self.assert_compile(
7070 select(table1, table4).select_from(
7071 join(table1, table4, table1.c.myid == table4.c.rem_id)
7072 ),
7073 "SELECT mytable.myid, mytable.name, mytable.description, "
7074 "foob.remotetable.rem_id, foob.remotetable.datatype_id, "
7075 "foob.remotetable.value FROM mytable JOIN foob.remotetable "
7076 "ON mytable.myid = foob.remotetable.rem_id",
7077 schema_translate_map=schema_translate_map,
7078 render_schema_translate=True,
7079 )
7080
7081 def test_schema_translate_aliases(self):
7082 schema_translate_map = {None: "bar"}

Callers

nothing calls this directly

Calls 9

MetaDataClass · 0.90
TableClass · 0.90
ColumnClass · 0.90
selectFunction · 0.90
joinFunction · 0.90
assert_compileMethod · 0.80
whereMethod · 0.45
selectMethod · 0.45
select_fromMethod · 0.45

Tested by

no test coverage detected