diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-09-16 13:38:11 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-09-16 13:40:47 -0400 |
| commit | 8fca5b6e6a42b6221faaf26a912603393afd8607 (patch) | |
| tree | d06793fc78d9835b040bf2a9d14b35e3da46162a /test/sql | |
| parent | c27bf6f7ecc1a120f0c8029eaa5969b6d2aa255d (diff) | |
| download | sqlalchemy-8fca5b6e6a42b6221faaf26a912603393afd8607.tar.gz | |
use the stack for insert_from_select
Fixed issue related to new ``add_cte()`` feature where pairing two
"INSERT..FROM SELECT" statements simultaneously would lose track of the two
independent SELECT statements, leading to the wrong SQL.
Fixes: #7036
Change-Id: I90fe47eb203bc5c1ea5810db0edba08250b2b7e6
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_cte.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/sql/test_cte.py b/test/sql/test_cte.py index cc663d53f..0680472ff 100644 --- a/test/sql/test_cte.py +++ b/test/sql/test_cte.py @@ -1583,6 +1583,29 @@ class CTETest(fixtures.TestBase, AssertsCompiledSQL): checkparams={"id": 1, "price": 20, "param_1": 10, "price_1": 50}, ) + def test_insert_from_select_uses_independent_cte(self): + """test #7036""" + + t1 = table("table1", column("id1"), column("a")) + + t2 = table("table2", column("id2"), column("b")) + + ins1 = t1.insert().from_select(["id1", "a"], select(1, text("'a'"))) + + cte1 = ins1.cte("cte1") + + ins2 = t2.insert().from_select(["id2", "b"], select(2, text("'b'"))) + + ins2 = ins2.add_cte(cte1) + + self.assert_compile( + ins2, + "WITH cte1 AS " + "(INSERT INTO table1 (id1, a) SELECT 1, 'a') " + "INSERT INTO table2 (id2, b) SELECT 2, 'b'", + checkparams={}, + ) + def test_update_uses_independent_cte(self): products = table("products", column("id"), column("price")) |
