summaryrefslogtreecommitdiff
path: root/test/sql/test_generative.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-06-10 17:24:36 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-06-10 17:24:36 -0400
commit7189d0bc82598c2d6dcbb55b054837416db2ee7d (patch)
treeab9a7536f194670323b14983300ce339e64fe970 /test/sql/test_generative.py
parent31a0da32a8af2503c6b94123a0e869816d83c707 (diff)
downloadsqlalchemy-7189d0bc82598c2d6dcbb55b054837416db2ee7d.tar.gz
Ensure CTE internals are handled during clone
The CTE construct was missing a _copy_internals() method which would handle CTE-specific structures including _cte_alias, _restates during a clone operation. Change-Id: I9aeac9cd24d8f7ae6b70e52650d61f7c96cb6d7e Fixes: #3722
Diffstat (limited to 'test/sql/test_generative.py')
-rw-r--r--test/sql/test_generative.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py
index 9cf1ef612..81c589d11 100644
--- a/test/sql/test_generative.py
+++ b/test/sql/test_generative.py
@@ -475,6 +475,23 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL):
"FROM table3 AS table3_1"
)
+ def test_cte_w_union(self):
+ t = select([func.values(1).label("n")]).cte("t", recursive=True)
+ t = t.union_all(select([t.c.n + 1]).where(t.c.n < 100))
+ s = select([func.sum(t.c.n)])
+
+ from sqlalchemy.sql.visitors import cloned_traverse
+ cloned = cloned_traverse(s, {}, {})
+
+ self.assert_compile(cloned,
+ "WITH RECURSIVE t(n) AS "
+ "(SELECT values(:values_1) AS n "
+ "UNION ALL SELECT t.n + :n_1 AS anon_1 "
+ "FROM t "
+ "WHERE t.n < :n_2) "
+ "SELECT sum(t.n) AS sum_1 FROM t"
+ )
+
def test_text(self):
clause = text(
"select * from table where foo=:bar",