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

Method test_union_all_lightweight

test/sql/test_query.py:1252–1272  ·  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

1250 eq_(found2, wanted)
1251
1252 def test_union_all_lightweight(self, connection):
1253 """like test_union_all, but breaks the sub-union into
1254 a subquery with an explicit column reference on the outside,
1255 more palatable to a wider variety of engines.
1256
1257 """
1258
1259 t1, t2, t3 = self.tables("t1", "t2", "t3")
1260
1261 u = union(select(t1.c.col3), select(t1.c.col3)).alias()
1262
1263 e = union_all(select(t1.c.col3), select(u.c.col3))
1264
1265 wanted = [("aaa",), ("aaa",), ("bbb",), ("bbb",), ("ccc",), ("ccc",)]
1266 found1 = self._fetchall_sorted(connection.execute(e))
1267 eq_(found1, wanted)
1268
1269 found2 = self._fetchall_sorted(
1270 connection.execute(e.alias("foo").select())
1271 )
1272 eq_(found2, wanted)
1273
1274 @testing.requires.intersect
1275 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