MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_recursive_union_alias_two

Method test_recursive_union_alias_two

test/sql/test_cte.py:329–344  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

327 )
328
329 def test_recursive_union_alias_two(self):
330 # I know, this is the PG VALUES keyword,
331 # we're cheating here. also yes we need the SELECT,
332 # sorry PG.
333 t = select(func.values(1).label("n")).cte("t", recursive=True)
334 t = t.union_all(select(t.c.n + 1).where(t.c.n < 100)).alias("ta")
335 s = select(func.sum(t.c.n))
336 self.assert_compile(
337 s,
338 "WITH RECURSIVE t(n) AS "
339 "(SELECT values(:values_1) AS n "
340 "UNION ALL SELECT t.n + :n_1 AS anon_1 "
341 "FROM t "
342 "WHERE t.n < :n_2) "
343 "SELECT sum(ta.n) AS sum_1 FROM t AS ta",
344 )
345
346 def test_recursive_union_no_alias_three(self):
347 # like test one, but let's refer to the CTE

Callers

nothing calls this directly

Calls 9

selectFunction · 0.90
assert_compileMethod · 0.80
cteMethod · 0.45
labelMethod · 0.45
valuesMethod · 0.45
aliasMethod · 0.45
union_allMethod · 0.45
whereMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected