diff options
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 11 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/expression.py | 19 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/operators.py | 16 |
3 files changed, 32 insertions, 14 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index f975225d6..49df9322e 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -948,8 +948,15 @@ class SQLCompiler(engine.Compiled): else: add_to_result_map = None - if isinstance(col_expr, sql.Label): - result_expr = col_expr + if isinstance(column, sql.Label): + if col_expr is not column: + result_expr = _CompileLabel( + col_expr, + column.name, + alt_names=(column.element,) + ) + else: + result_expr = col_expr elif select is not None and \ select.use_labels and \ 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. """ diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py index ba1117ef6..07fb417fb 100644 --- a/lib/sqlalchemy/sql/operators.py +++ b/lib/sqlalchemy/sql/operators.py @@ -205,7 +205,8 @@ class custom_op(object): class ColumnOperators(Operators): - """Defines comparison and math operations. + """Defines boolean, comparison, and other operators for + :class:`.ColumnElement` expressions. By default, all methods call down to :meth:`.operate` or :meth:`.reverse_operate`, @@ -229,10 +230,15 @@ class ColumnOperators(Operators): so that the ``==`` operation above is replaced by a clause construct. - The docstrings here will describe column-oriented - behavior of each operator. For ORM-based operators - on related objects and collections, see - :class:`.RelationshipProperty.Comparator`. + See also: + + :ref:`types_operators` + + :attr:`.TypeEngine.comparator_factory` + + :class:`.ColumnOperators` + + :class:`.PropComparator` """ |