| 367 | ) |
| 368 | |
| 369 | def test_recursive_union_alias_three(self): |
| 370 | # like test one, but let's refer to the CTE |
| 371 | # in a sibling CTE. |
| 372 | |
| 373 | s1 = select(literal(0).label("x")) |
| 374 | cte = s1.cte(name="cte", recursive=True) |
| 375 | |
| 376 | # can't do it here... |
| 377 | # bar = select(cte).cte('bar') |
| 378 | cte = cte.union_all(select(cte.c.x + 1).where(cte.c.x < 10)).alias( |
| 379 | "cs1" |
| 380 | ) |
| 381 | bar = select(cte).cte("bar").alias("cs2") |
| 382 | |
| 383 | s2 = select(cte, bar) |
| 384 | self.assert_compile( |
| 385 | s2, |
| 386 | "WITH RECURSIVE cte(x) AS " |
| 387 | "(SELECT :param_1 AS x UNION ALL " |
| 388 | "SELECT cte.x + :x_2 AS anon_1 " |
| 389 | "FROM cte WHERE cte.x < :x_3), " |
| 390 | "bar AS (SELECT cs1.x AS x FROM cte AS cs1) " |
| 391 | "SELECT cs1.x, cs2.x AS x_1 FROM cte AS cs1, bar AS cs2", |
| 392 | ) |
| 393 | |
| 394 | def test_recursive_union_no_alias_four(self): |
| 395 | # like test one and three, but let's refer |