diff options
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r-- | lib/sqlalchemy/sql/expression.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 63fa23c15..e8905ccec 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -174,8 +174,8 @@ def select(columns=None, whereclause=None, from_obj=[], **kwargs): See also: - :ref:`coretutorial_selecting` - Core Tutorial description - of :func:`.select`. + :ref:`coretutorial_selecting` - Core Tutorial description of + :func:`.select`. :param columns: A list of :class:`.ClauseElement` objects, typically @@ -899,9 +899,14 @@ def type_coerce(expr, type_): ) """ + type_ = sqltypes.to_instance(type_) + if hasattr(expr, '__clause_expr__'): return type_coerce(expr.__clause_expr__()) - + elif isinstance(expr, BindParameter): + bp = expr._clone() + bp.type = type_ + return bp elif not isinstance(expr, Visitable): if expr is None: return null() @@ -1177,7 +1182,7 @@ def over(func, partition_by=None, order_by=None): Would produce "ROW_NUMBER() OVER(ORDER BY x)". :param func: a :class:`.FunctionElement` construct, typically - generated by :attr:`~.expression.func`. + generated by :data:`~.expression.func`. :param partition_by: a column element or string, or a list of such, that will be used as the PARTITION BY clause of the OVER construct. @@ -1185,7 +1190,7 @@ def over(func, partition_by=None, order_by=None): of such, that will be used as the ORDER BY clause of the OVER construct. - This function is also available from the :attr:`~.expression.func` + This function is also available from the :data:`~.expression.func` construct itself via the :meth:`.FunctionElement.over` method. .. versionadded:: 0.7 @@ -2867,7 +2872,7 @@ class BindParameter(ColumnElement): if type_ is None: if _compared_to_type is not None: self.type = \ - _compared_to_type._coerce_compared_value( + _compared_to_type.coerce_compared_value( _compared_to_operator, value) else: self.type = sqltypes._type_map.get(type(value), @@ -3470,7 +3475,7 @@ class Function(FunctionElement): def __init__(self, name, *clauses, **kw): """Construct a :class:`.Function`. - The :attr:`.func` construct is normally used to construct + The :data:`.func` construct is normally used to construct new :class:`.Function` instances. """ |