| 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 |