MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_insert_update_w_add_cte

Method test_insert_update_w_add_cte

test/sql/test_cte.py:1495–1518  ·  view source on GitHub ↗

test #10408

(self)

Source from the content-addressed store, hash-verified

1493 )
1494
1495 def test_insert_update_w_add_cte(self):
1496 """test #10408"""
1497 a = table(
1498 "a", column("id"), column("x"), column("y"), column("next_id")
1499 )
1500
1501 insert_a_cte = (insert(a).values(x=10, y=15).returning(a.c.id)).cte(
1502 "insert_a_cte"
1503 )
1504
1505 update_query = (
1506 update(a)
1507 .values(next_id=insert_a_cte.c.id)
1508 .where(a.c.id == 10)
1509 .add_cte(insert_a_cte)
1510 )
1511
1512 self.assert_compile(
1513 update_query,
1514 "WITH insert_a_cte AS (INSERT INTO a (x, y) "
1515 "VALUES (:param_1, :param_2) RETURNING a.id) "
1516 "UPDATE a SET next_id=insert_a_cte.id "
1517 "FROM insert_a_cte WHERE a.id = :id_1",
1518 )
1519
1520 def test_anon_update_cte(self):
1521 orders = table("orders", column("region"))

Callers

nothing calls this directly

Calls 10

tableFunction · 0.90
columnFunction · 0.90
insertFunction · 0.90
updateFunction · 0.90
assert_compileMethod · 0.80
cteMethod · 0.45
returningMethod · 0.45
valuesMethod · 0.45
add_cteMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected