summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-03-23 15:11:03 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-03-23 15:31:05 -0400
commit0883d8213bcfbeb5e0ae6dd1cbcf70494eb06dac (patch)
tree71282de7e6a7878dbb8d8b309be625cbfcbae887 /lib/sqlalchemy/sql
parent1fcbc17b7dd5a5cad71ee79441aa3293c00b8877 (diff)
downloadsqlalchemy-0883d8213bcfbeb5e0ae6dd1cbcf70494eb06dac.tar.gz
Treat collation names as identifiers
The expression used for COLLATE as rendered by the column-level :func:`.expression.collate` and :meth:`.ColumnOperators.collate` is now quoted as an identifier when the name is case sensitive, e.g. has uppercase characters. Note that this does not impact type-level collation, which is already quoted. Change-Id: I83d5d9cd1e66a4f20b96303bb84c5f360d5d6a1a Fixes: #3785
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/elements.py8
-rw-r--r--lib/sqlalchemy/sql/operators.py8
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index a450efaf0..1f8129382 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -41,12 +41,18 @@ def collate(expression, collation):
mycolumn COLLATE utf8_bin
+ The collation expression is also quoted if it is a case sensitive
+ identifer, e.g. contains uppercase characters.
+
+ .. versionchanged:: 1.2 quoting is automatically applied to COLLATE
+ expressions if they are case sensitive.
+
"""
expr = _literal_as_binds(expression)
return BinaryExpression(
expr,
- _literal_as_text(collation),
+ ColumnClause(collation),
operators.collate, type_=expr.type)
diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py
index 8f697b27e..49642acdd 100644
--- a/lib/sqlalchemy/sql/operators.py
+++ b/lib/sqlalchemy/sql/operators.py
@@ -695,7 +695,13 @@ class ColumnOperators(Operators):
def collate(self, collation):
"""Produce a :func:`~.expression.collate` clause against
- the parent object, given the collation string."""
+ the parent object, given the collation string.
+
+ .. seealso::
+
+ :func:`~.expression.collate`
+
+ """
return self.operate(collate, collation)
def __radd__(self, other):