test #12363
(self, num_ctes)
| 1902 | |
| 1903 | @testing.variation("num_ctes", ["one", "two"]) |
| 1904 | def test_multiple_multivalues_inserts(self, num_ctes): |
| 1905 | """test #12363""" |
| 1906 | |
| 1907 | t1 = table("table1", column("id"), column("a"), column("b")) |
| 1908 | |
| 1909 | t2 = table("table2", column("id"), column("a"), column("b")) |
| 1910 | |
| 1911 | if num_ctes.one: |
| 1912 | self.assert_compile( |
| 1913 | insert(t1) |
| 1914 | .values([{"a": 1}, {"a": 2}]) |
| 1915 | .add_cte(insert(t2).values([{"a": 5}, {"a": 6}]).cte()), |
| 1916 | "WITH anon_1 AS " |
| 1917 | "(INSERT INTO table2 (a) VALUES (:param_1), (:param_2)) " |
| 1918 | "INSERT INTO table1 (a) VALUES (:a_m0), (:a_m1)", |
| 1919 | ) |
| 1920 | |
| 1921 | elif num_ctes.two: |
| 1922 | self.assert_compile( |
| 1923 | insert(t1) |
| 1924 | .values([{"a": 1}, {"a": 2}]) |
| 1925 | .add_cte(insert(t1).values([{"b": 5}, {"b": 6}]).cte()) |
| 1926 | .add_cte(insert(t2).values([{"a": 5}, {"a": 6}]).cte()), |
| 1927 | "WITH anon_1 AS " |
| 1928 | "(INSERT INTO table1 (b) VALUES (:param_1), (:param_2)), " |
| 1929 | "anon_2 AS " |
| 1930 | "(INSERT INTO table2 (a) VALUES (:param_3), (:param_4)) " |
| 1931 | "INSERT INTO table1 (a) VALUES (:a_m0), (:a_m1)", |
| 1932 | ) |
| 1933 | |
| 1934 | def test_insert_from_select_uses_independent_cte(self): |
| 1935 | """test #7036""" |