MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_cte_w_annotated

Method test_cte_w_annotated

test/sql/test_cte.py:543–566  ·  view source on GitHub ↗

test #12364

(self, annotated)

Source from the content-addressed store, hash-verified

541
542 @testing.variation("annotated", [True, False])
543 def test_cte_w_annotated(self, annotated):
544 """test #12364"""
545
546 A = table("a", column("i"), column("j"))
547 B = table("b", column("i"), column("j"))
548
549 a = select(A).where(A.c.i > A.c.j).cte("filtered_a")
550
551 if annotated:
552 a = a._annotate({"foo": "bar"})
553
554 a1 = select(a.c.i, literal(1).label("j"))
555 b = select(B).join(a, a.c.i == B.c.i).where(B.c.j.is_not(None))
556
557 query = union_all(a1, b)
558 self.assert_compile(
559 query,
560 "WITH filtered_a AS "
561 "(SELECT a.i AS i, a.j AS j FROM a WHERE a.i > a.j) "
562 "SELECT filtered_a.i, :param_1 AS j FROM filtered_a "
563 "UNION ALL SELECT b.i, b.j "
564 "FROM b JOIN filtered_a ON filtered_a.i = b.i "
565 "WHERE b.j IS NOT NULL",
566 )
567
568 def test_with_recursive_no_name_currently_buggy(self):
569 s1 = select(1)

Callers

nothing calls this directly

Calls 12

tableFunction · 0.90
columnFunction · 0.90
selectFunction · 0.90
literalFunction · 0.90
union_allFunction · 0.90
assert_compileMethod · 0.80
cteMethod · 0.45
whereMethod · 0.45
_annotateMethod · 0.45
labelMethod · 0.45
joinMethod · 0.45
is_notMethod · 0.45

Tested by

no test coverage detected