MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_cte_w_union

Method test_cte_w_union

test/sql/test_external_traversal.py:752–769  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

750 )
751
752 def test_cte_w_union(self):
753 t = select(func.values(1).label("n")).cte("t", recursive=True)
754 t = t.union_all(select(t.c.n + 1).where(t.c.n < 100))
755 s = select(func.sum(t.c.n))
756
757 from sqlalchemy.sql.visitors import cloned_traverse
758
759 cloned = cloned_traverse(s, {}, {})
760
761 self.assert_compile(
762 cloned,
763 "WITH RECURSIVE t(n) AS "
764 "(SELECT values(:values_1) AS n "
765 "UNION ALL SELECT t.n + :n_1 AS anon_1 "
766 "FROM t "
767 "WHERE t.n < :n_2) "
768 "SELECT sum(t.n) AS sum_1 FROM t",
769 )
770
771 def test_aliased_cte_w_union(self):
772 t = (

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected