summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-05-23 21:21:39 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-05-23 21:21:39 +0000
commit906bb6533d900dd0bcc84007c3abe8aa0701acfd (patch)
tree9743175496f3a239e2692cc40596e7de13d5b1ec /lib
parenta2e8e773c5d4b564a5a7a83711ae0378e2fbc6a0 (diff)
parentd163088de1d68919b6811a25745d3becbbf5b069 (diff)
downloadsqlalchemy-906bb6533d900dd0bcc84007c3abe8aa0701acfd.tar.gz
Merge "Correctly apply self_group in type_coerce element."
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/sql/elements.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index 43115f117..7310edd3f 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -2823,14 +2823,11 @@ class TypeCoerce(WrapsColumnExpression, ColumnElement):
renders SQL that labels the expression, but otherwise does not
modify its value on the SQL side::
- SELECT date_string AS anon_1 FROM log
+ SELECT date_string AS date_string FROM log
- When result rows are fetched, the ``StringDateTime`` type
+ When result rows are fetched, the ``StringDateTime`` type processor
will be applied to result rows on behalf of the ``date_string`` column.
- The rationale for the "anon_1" label is so that the type-coerced
- column remains separate in the list of result columns vs. other
- type-coerced or direct values of the target column. In order to
- provide a named label for the expression, use
+ In order to provide a named label for the expression, use
:meth:`_expression.ColumnElement.label`::
stmt = select([
@@ -2893,6 +2890,13 @@ class TypeCoerce(WrapsColumnExpression, ColumnElement):
def wrapped_column_expression(self):
return self.clause
+ def self_group(self, against=None):
+ grouped = self.clause.self_group(against=against)
+ if grouped is not self.clause:
+ return TypeCoerce(grouped, self.type)
+ else:
+ return self
+
class Extract(ColumnElement):
"""Represent a SQL EXTRACT clause, ``extract(field FROM expr)``."""