MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_insert_uses_independent_cte

Method test_insert_uses_independent_cte

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

Source from the content-addressed store, hash-verified

1882 )
1883
1884 def test_insert_uses_independent_cte(self):
1885 products = table("products", column("id"), column("price"))
1886
1887 upd_cte = (
1888 products.update().values(price=10).where(products.c.price > 50)
1889 ).cte()
1890
1891 stmt = (
1892 products.insert().values({"id": 1, "price": 20}).add_cte(upd_cte)
1893 )
1894
1895 self.assert_compile(
1896 stmt,
1897 "WITH anon_1 AS (UPDATE products SET price=:param_1 "
1898 "WHERE products.price > :price_1) "
1899 "INSERT INTO products (id, price) VALUES (:id, :price)",
1900 checkparams={"id": 1, "price": 20, "param_1": 10, "price_1": 50},
1901 )
1902
1903 @testing.variation("num_ctes", ["one", "two"])
1904 def test_multiple_multivalues_inserts(self, num_ctes):

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
insertMethod · 0.45

Tested by

no test coverage detected