MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_alias_union

Method test_alias_union

test/sql/test_selectable.py:1070–1105  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1068 assert u.selected_columns.col3 is not None
1069
1070 def test_alias_union(self):
1071 # same as testunion, except its an alias of the union
1072
1073 u = (
1074 select(
1075 table1.c.col1,
1076 table1.c.col2,
1077 table1.c.col3,
1078 table1.c.colx,
1079 null().label("coly"),
1080 )
1081 .union(
1082 select(
1083 table2.c.col1,
1084 table2.c.col2,
1085 table2.c.col3,
1086 null().label("colx"),
1087 table2.c.coly,
1088 )
1089 )
1090 .alias("analias")
1091 )
1092 s1 = (
1093 table1.select()
1094 .set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL)
1095 .subquery()
1096 )
1097 s2 = (
1098 table2.select()
1099 .set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL)
1100 .subquery()
1101 )
1102 assert u.corresponding_column(s1.c.table1_col2) is u.c.col2
1103 assert u.corresponding_column(s2.c.table2_col2) is u.c.col2
1104 assert u.corresponding_column(s2.c.table2_coly) is u.c.coly
1105 assert s2.corresponding_column(u.c.coly) is s2.c.table2_coly
1106
1107 def test_union_of_alias(self):
1108 s1 = select(table1.c.col1, table1.c.col2)

Callers

nothing calls this directly

Calls 9

selectFunction · 0.90
nullFunction · 0.90
aliasMethod · 0.45
unionMethod · 0.45
labelMethod · 0.45
subqueryMethod · 0.45
set_label_styleMethod · 0.45
selectMethod · 0.45
corresponding_columnMethod · 0.45

Tested by

no test coverage detected