MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_select_uses_independent_cte

Method test_select_uses_independent_cte

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

Source from the content-addressed store, hash-verified

1768 eq_(stmt.compile().isdelete, True)
1769
1770 def test_select_uses_independent_cte(self):
1771 products = table("products", column("id"), column("price"))
1772
1773 upd_cte = (
1774 products.update().values(price=10).where(products.c.price > 50)
1775 ).cte()
1776
1777 stmt = products.select().where(products.c.price < 45).add_cte(upd_cte)
1778
1779 self.assert_compile(
1780 stmt,
1781 "WITH anon_1 AS (UPDATE products SET price=:param_1 "
1782 "WHERE products.price > :price_1) "
1783 "SELECT products.id, products.price "
1784 "FROM products WHERE products.price < :price_2",
1785 checkparams={"param_1": 10, "price_1": 50, "price_2": 45},
1786 )
1787
1788 def test_compound_select_uses_independent_cte(self):
1789 products = table("products", column("id"), column("price"))

Callers

nothing calls this directly

Calls 9

tableFunction · 0.90
columnFunction · 0.90
assert_compileMethod · 0.80
cteMethod · 0.45
whereMethod · 0.45
valuesMethod · 0.45
updateMethod · 0.45
add_cteMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected