test #10167
(self, stmt_type: testing.Variation)
| 627 | |
| 628 | @testing.variation("stmt_type", ["core", "orm"]) |
| 629 | def test_add_cte(self, stmt_type: testing.Variation): |
| 630 | """test #10167""" |
| 631 | |
| 632 | if stmt_type.orm: |
| 633 | User = self.classes.User |
| 634 | cte_select = select(User.name).limit(1).cte() |
| 635 | cte_insert = insert(User).from_select(["name"], cte_select).cte() |
| 636 | elif stmt_type.core: |
| 637 | user_table = self.tables.users |
| 638 | cte_select = select(user_table.c.name).limit(1).cte() |
| 639 | cte_insert = ( |
| 640 | insert(user_table).from_select(["name"], cte_select).cte() |
| 641 | ) |
| 642 | else: |
| 643 | stmt_type.fail() |
| 644 | |
| 645 | select_stmt = select(cte_select).add_cte(cte_insert) |
| 646 | |
| 647 | self.assert_compile( |
| 648 | select_stmt, |
| 649 | "WITH anon_2 AS (SELECT users.name AS name FROM users LIMIT " |
| 650 | ":param_1), anon_1 AS (INSERT INTO users (name) " |
| 651 | "SELECT anon_2.name AS name FROM anon_2) " |
| 652 | "SELECT anon_2.name FROM anon_2", |
| 653 | ) |
| 654 | |
| 655 | |
| 656 | class ColumnsClauseFromsTest(QueryTest, AssertsCompiledSQL): |
nothing calls this directly
no test coverage detected