MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_recursive_union_no_alias_three

Method test_recursive_union_no_alias_three

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

Source from the content-addressed store, hash-verified

344 )
345
346 def test_recursive_union_no_alias_three(self):
347 # like test one, but let's refer to the CTE
348 # in a sibling CTE.
349
350 s1 = select(literal(0).label("x"))
351 cte = s1.cte(name="cte", recursive=True)
352
353 # can't do it here...
354 # bar = select(cte).cte('bar')
355 cte = cte.union_all(select(cte.c.x + 1).where(cte.c.x < 10))
356 bar = select(cte).cte("bar")
357
358 s2 = select(cte, bar)
359 self.assert_compile(
360 s2,
361 "WITH RECURSIVE cte(x) AS "
362 "(SELECT :param_1 AS x UNION ALL "
363 "SELECT cte.x + :x_2 AS anon_1 "
364 "FROM cte WHERE cte.x < :x_3), "
365 "bar AS (SELECT cte.x AS x FROM cte) "
366 "SELECT cte.x, bar.x AS x_1 FROM cte, bar",
367 )
368
369 def test_recursive_union_alias_three(self):
370 # like test one, but let's refer to the CTE

Callers

nothing calls this directly

Calls 7

selectFunction · 0.90
literalFunction · 0.90
assert_compileMethod · 0.80
labelMethod · 0.45
cteMethod · 0.45
union_allMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected