MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_union_all_lightweight

Method test_union_all_lightweight

test/sql/test_query.py:1184–1204  ·  view source on GitHub ↗

like test_union_all, but breaks the sub-union into a subquery with an explicit column reference on the outside, more palatable to a wider variety of engines.

(self, connection)

Source from the content-addressed store, hash-verified

1182 eq_(found2, wanted)
1183
1184 def test_union_all_lightweight(self, connection):
1185 """like test_union_all, but breaks the sub-union into
1186 a subquery with an explicit column reference on the outside,
1187 more palatable to a wider variety of engines.
1188
1189 """
1190
1191 t1, t2, t3 = self.tables("t1", "t2", "t3")
1192
1193 u = union(select(t1.c.col3), select(t1.c.col3)).alias()
1194
1195 e = union_all(select(t1.c.col3), select(u.c.col3))
1196
1197 wanted = [("aaa",), ("aaa",), ("bbb",), ("bbb",), ("ccc",), ("ccc",)]
1198 found1 = self._fetchall_sorted(connection.execute(e))
1199 eq_(found1, wanted)
1200
1201 found2 = self._fetchall_sorted(
1202 connection.execute(e.alias("foo").select())
1203 )
1204 eq_(found2, wanted)
1205
1206 @testing.requires.intersect
1207 def test_intersect(self, connection):

Callers

nothing calls this directly

Calls 8

_fetchall_sortedMethod · 0.95
unionFunction · 0.90
selectFunction · 0.90
union_allFunction · 0.90
eq_Function · 0.90
aliasMethod · 0.45
executeMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected