MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_delete_against_user_textual_cte

Method test_delete_against_user_textual_cte

test/sql/test_cte.py:1744–1768  ·  view source on GitHub ↗

test #6464. Test the user's exact arrangement.

(self)

Source from the content-addressed store, hash-verified

1742 eq_(stmt.compile().isdelete, True)
1743
1744 def test_delete_against_user_textual_cte(self):
1745 """test #6464.
1746
1747 Test the user's exact arrangement.
1748
1749 """
1750
1751 q = select(
1752 text(
1753 "name, date_hour, "
1754 "ROW_NUMBER() OVER(PARTITION BY name, date_hour "
1755 "ORDER BY value DESC)"
1756 " AS RN FROM testtable"
1757 )
1758 )
1759 cte = q.cte("deldup")
1760 stmt = delete(cte).where(text("RN > 1"))
1761
1762 self.assert_compile(
1763 stmt,
1764 "WITH deldup AS (SELECT name, date_hour, ROW_NUMBER() "
1765 "OVER(PARTITION BY name, date_hour ORDER BY value DESC) "
1766 "AS RN FROM testtable) DELETE FROM deldup WHERE RN > 1",
1767 )
1768 eq_(stmt.compile().isdelete, True)
1769
1770 def test_select_uses_independent_cte(self):
1771 products = table("products", column("id"), column("price"))

Callers

nothing calls this directly

Calls 8

selectFunction · 0.90
textFunction · 0.90
deleteFunction · 0.90
eq_Function · 0.90
assert_compileMethod · 0.80
cteMethod · 0.45
whereMethod · 0.45
compileMethod · 0.45

Tested by

no test coverage detected