summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-05-25 14:08:41 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-05-25 14:09:08 -0400
commit076eef5afb47cc133f90d3cf9a848ad4e09a4c51 (patch)
tree5f75c1dba767c8ab8f2250621b65c23456bf6728 /test
parent64e887b2e399971513b2761979bb2f740816d4b7 (diff)
downloadsqlalchemy-076eef5afb47cc133f90d3cf9a848ad4e09a4c51.tar.gz
- Fixed bug in INSERT..FROM SELECT construct where selecting from a
UNION would wrap the union in an anonymous (e.g. unlabled) subquery. fixes #3044
Diffstat (limited to 'test')
-rw-r--r--test/sql/test_insert.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py
index 8a5c7cd83..d9f7b1629 100644
--- a/test/sql/test_insert.py
+++ b/test/sql/test_insert.py
@@ -196,7 +196,25 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
checkparams={}
)
-
+ def test_insert_from_select_union(self):
+ mytable = self.tables.mytable
+
+ name = 'name'
+ description = 'desc'
+ sel = select(
+ [name, mytable.c.description],
+ ).union(
+ select([name, description])
+ )
+ ins = mytable.insert().\
+ from_select(
+ [mytable.c.name, mytable.c.description], sel)
+ self.assert_compile(
+ ins,
+ "INSERT INTO mytable (name, description) "
+ "SELECT name, mytable.description FROM mytable "
+ "UNION SELECT name, desc"
+ )
def test_insert_from_select_col_values(self):
table1 = self.tables.mytable
table2 = self.tables.myothertable