diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-08-07 18:59:05 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-08-08 17:29:32 -0400 |
commit | f03c7918796e1080d971a9c03943962478be4caf (patch) | |
tree | 1fc625022979151be27a9a3403726a4d2179f44d /lib/sqlalchemy/sql/compiler.py | |
parent | b17fa2513e412b8f9aa1f62c0acc7fa3805e632b (diff) | |
download | sqlalchemy-f03c7918796e1080d971a9c03943962478be4caf.tar.gz |
Fixed issue with :meth:`.TypeEngine.bind_expression` and
:meth:`.TypeEngine.column_expression` methods where these methods would not
work if the target type were part of a :class:`.Variant`, or other target
type of a :class:`.TypeDecorator`. Additionally, the SQL compiler now
calls upon the dialect-level implementation when it renders these methods
so that dialects can now provide for SQL-level processing for built-in
types.
Change-Id: Ic7b39575184db582e628e6ecee48dcda7d03a817
Fixes: #3981
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 57da43217..5fbc7d87f 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1237,10 +1237,17 @@ class SQLCompiler(Compiled): literal_binds=False, skip_bind_expression=False, **kwargs): - if not skip_bind_expression and bindparam.type._has_bind_expression: - bind_expression = bindparam.type.bind_expression(bindparam) - return self.process(bind_expression, - skip_bind_expression=True) + + if not skip_bind_expression: + impl = bindparam.type.dialect_impl(self.dialect) + if impl._has_bind_expression: + bind_expression = impl.bind_expression(bindparam) + return self.process( + bind_expression, skip_bind_expression=True, + within_columns_clause=within_columns_clause, + literal_binds=literal_binds, + **kwargs + ) if literal_binds or \ (within_columns_clause and @@ -1510,10 +1517,12 @@ class SQLCompiler(Compiled): within_columns_clause=True): """produce labeled columns present in a select().""" - if column.type._has_column_expression and \ + impl = column.type.dialect_impl(self.dialect) + if impl._has_column_expression and \ populate_result_map: - col_expr = column.type.column_expression(column) - add_to_result_map = lambda keyname, name, objects, type_: \ + col_expr = impl.column_expression(column) + + def add_to_result_map(keyname, name, objects, type_): self._add_to_result_map( keyname, name, (column,) + objects, type_) |