summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-03-08 13:40:12 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-03-08 13:40:12 -0500
commitc36965ab211183764357456fff1640418586ed97 (patch)
tree5e86792149df2f4188b0f363b5520f686312b6fb /test/dialect/postgresql/test_compiler.py
parent956ef43c5f858e6adb3bf00df0063a389ba567fc (diff)
downloadsqlalchemy-c36965ab211183764357456fff1640418586ed97.tar.gz
pop the stack that we pushed
Fixed regression caused by :ticket:`7760` where the new capabilities of :class:`.TextualSelect` were not fully implemented within the compiler properly, leading to issues with composed INSERT constructs such as "INSERT FROM SELECT" and "INSERT...ON CONFLICT" when combined with CTE and textual statements. Fixes: #7798 Change-Id: Ia2ce92507e574dd36fd26dd38ec9dd2713584467
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index 98b974ea5..2221fd30a 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -2321,6 +2321,28 @@ class InsertOnConflictTest(fixtures.TestBase, AssertsCompiledSQL):
):
meth()
+ def test_on_conflict_cte_plus_textual(self):
+ """test #7798"""
+
+ bar = table("bar", column("id"), column("attr"), column("foo_id"))
+ s1 = text("SELECT bar.id, bar.attr FROM bar").columns(
+ bar.c.id, bar.c.attr
+ )
+ s2 = (
+ insert(bar)
+ .from_select(list(s1.selected_columns), s1)
+ .on_conflict_do_update(
+ index_elements=[s1.selected_columns.id],
+ set_={"attr": s1.selected_columns.attr},
+ )
+ )
+
+ self.assert_compile(
+ s2,
+ "INSERT INTO bar (id, attr) SELECT bar.id, bar.attr "
+ "FROM bar ON CONFLICT (id) DO UPDATE SET attr = bar.attr",
+ )
+
def test_do_nothing_no_target(self):
i = (