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

Method test_schema_translate_select

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

Source from the content-addressed store, hash-verified

6831 )
6832
6833 def test_schema_translate_select(self):
6834 m = MetaData()
6835 table1 = Table(
6836 "mytable",
6837 m,
6838 Column("myid", Integer),
6839 Column("name", String),
6840 Column("description", String),
6841 )
6842 schema_translate_map = {"remote_owner": "foob", None: "bar"}
6843
6844 self.assert_compile(
6845 table1.select().where(table1.c.name == "hi"),
6846 "SELECT bar.mytable.myid, bar.mytable.name, "
6847 "bar.mytable.description FROM bar.mytable "
6848 "WHERE bar.mytable.name = :name_1",
6849 schema_translate_map=schema_translate_map,
6850 render_schema_translate=True,
6851 )
6852
6853 self.assert_compile(
6854 table4.select().where(table4.c.value == "hi"),
6855 "SELECT foob.remotetable.rem_id, foob.remotetable.datatype_id, "
6856 "foob.remotetable.value FROM foob.remotetable "
6857 "WHERE foob.remotetable.value = :value_1",
6858 schema_translate_map=schema_translate_map,
6859 render_schema_translate=True,
6860 )
6861
6862 schema_translate_map = {"remote_owner": "foob"}
6863 self.assert_compile(
6864 select(table1, table4).select_from(
6865 join(table1, table4, table1.c.myid == table4.c.rem_id)
6866 ),
6867 "SELECT mytable.myid, mytable.name, mytable.description, "
6868 "foob.remotetable.rem_id, foob.remotetable.datatype_id, "
6869 "foob.remotetable.value FROM mytable JOIN foob.remotetable "
6870 "ON mytable.myid = foob.remotetable.rem_id",
6871 schema_translate_map=schema_translate_map,
6872 render_schema_translate=True,
6873 )
6874
6875 def test_schema_translate_aliases(self):
6876 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