test #6464. Test the user's exact arrangement.
(self)
| 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")) |