summaryrefslogtreecommitdiff
path: root/test/sql/test_insert.py
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:08:41 -0400
commit482a67e1c68d3123ab91f8141ae58c7daa88e6db (patch)
tree09d88bb4d8050032dc98cfa2ff73c80646da9122 /test/sql/test_insert.py
parente384347ffb9b29fca146df54284e96a567adae9c (diff)
downloadsqlalchemy-482a67e1c68d3123ab91f8141ae58c7daa88e6db.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/sql/test_insert.py')
-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