MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_update_uses_independent_cte

Method test_update_uses_independent_cte

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

Source from the content-addressed store, hash-verified

1955 )
1956
1957 def test_update_uses_independent_cte(self):
1958 products = table("products", column("id"), column("price"))
1959
1960 upd_cte = (
1961 products.update().values(price=10).where(products.c.price > 50)
1962 ).cte()
1963
1964 stmt = (
1965 products.update()
1966 .values(price=5)
1967 .where(products.c.price < 50)
1968 .add_cte(upd_cte)
1969 )
1970
1971 self.assert_compile(
1972 stmt,
1973 "WITH anon_1 AS (UPDATE products SET price=:param_1 "
1974 "WHERE products.price > :price_1) UPDATE products "
1975 "SET price=:price WHERE products.price < :price_2",
1976 checkparams={
1977 "param_1": 10,
1978 "price": 5,
1979 "price_1": 50,
1980 "price_2": 50,
1981 },
1982 )
1983
1984 def test_update_w_insert_independent_cte(self):
1985 products = table("products", column("id"), column("price"))

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected