summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authorEric Atkin <eatkin@omnisolutions.biz>2018-02-22 14:16:14 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2018-02-22 15:06:01 -0500
commitb6e4a16809744255213a4598dc49a9cff9738b0b (patch)
tree0c9ea8faf57389d41c64ad5d0d81a02ebf67f457 /lib/sqlalchemy/sql/compiler.py
parent5614bffb2549b0aae2e7e41fe10bed12e06f457d (diff)
downloadsqlalchemy-b6e4a16809744255213a4598dc49a9cff9738b0b.tar.gz
Quote cte alias if needed
Fixed bug where CTE expressions would not have their name or alias name quoted when the given name is case sensitive or otherwise requires quoting. Pull request courtesy Eric Atkin. Fixes: #4197 Change-Id: Ib8573e82b9a1ca94b50c7c5d73ee98b79465d689 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/426
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 560585cab..be41e80c5 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -1427,6 +1427,8 @@ class SQLCompiler(Compiled):
if asfrom:
if cte_alias_name:
text = self.preparer.format_alias(cte, cte_alias_name)
+ if self.preparer._requires_quotes(cte_name):
+ cte_name = self.preparer.quote(cte_name)
text += self.get_render_as_alias_suffix(cte_name)
else:
return self.preparer.format_alias(cte, cte_name)