diff options
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r-- | lib/sqlalchemy/sql/elements.py | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index e857f2da8..858695719 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -12,18 +12,25 @@ from __future__ import unicode_literals -from .. import util, exc, inspection -from . import type_api -from . import operators -from .visitors import Visitable, cloned_traverse, traverse -from .annotation import Annotated import itertools -from .base import Executable, PARSE_AUTOCOMMIT, Immutable, NO_ARG -from .base import _generative import numbers - -import re import operator +import re + +from . import operators +from . import type_api +from .annotation import Annotated +from .base import _generative +from .base import Executable +from .base import Immutable +from .base import NO_ARG +from .base import PARSE_AUTOCOMMIT +from .visitors import cloned_traverse +from .visitors import traverse +from .visitors import Visitable +from .. import exc +from .. import inspection +from .. import util def _clone(element, **kw): @@ -450,7 +457,9 @@ class ClauseElement(Visitable): if util.py3k: return str(self.compile()) else: - return unicode(self.compile()).encode("ascii", "backslashreplace") + return unicode(self.compile()).encode( # noqa + "ascii", "backslashreplace" + ) # noqa def __and__(self, other): """'and' at the ClauseElement level. @@ -1244,8 +1253,8 @@ class TypeClause(ClauseElement): __visit_name__ = "typeclause" - def __init__(self, type): - self.type = type + def __init__(self, type_): + self.type = type_ class TextClause(Executable, ClauseElement): @@ -1609,10 +1618,10 @@ class TextClause(Executable, ClauseElement): for id, name, timestamp in connection.execute(stmt): print(id, name, timestamp) - The positional form of :meth:`.TextClause.columns` also provides - the unique feature of **positional column targeting**, which is - particularly useful when using the ORM with complex textual queries. - If we specify the columns from our model to :meth:`.TextClause.columns`, + The positional form of :meth:`.TextClause.columns` also provides the + unique feature of **positional column targeting**, which is + particularly useful when using the ORM with complex textual queries. If + we specify the columns from our model to :meth:`.TextClause.columns`, the result set will match to those columns positionally, meaning the name or origin of the column in the textual SQL doesn't matter:: @@ -2382,7 +2391,7 @@ class Cast(ColumnElement): __visit_name__ = "cast" def __init__(self, expression, type_): - """Produce a ``CAST`` expression. + r"""Produce a ``CAST`` expression. :func:`.cast` returns an instance of :class:`.Cast`. @@ -2421,7 +2430,7 @@ class Cast(ColumnElement): expression or a Python string which will be coerced into a bound literal value. - :param type_: A :class:`.TypeEngine` class or instance indicating + :param type\_: A :class:`.TypeEngine` class or instance indicating the type to which the ``CAST`` should apply. .. seealso:: @@ -2465,7 +2474,7 @@ class TypeCoerce(ColumnElement): __visit_name__ = "type_coerce" def __init__(self, expression, type_): - """Associate a SQL expression with a particular type, without rendering + r"""Associate a SQL expression with a particular type, without rendering ``CAST``. E.g.:: @@ -2517,7 +2526,7 @@ class TypeCoerce(ColumnElement): expression or a Python string which will be coerced into a bound literal value. - :param type_: A :class:`.TypeEngine` class or instance indicating + :param type\_: A :class:`.TypeEngine` class or instance indicating the type to which the expression is coerced. .. seealso:: @@ -3234,7 +3243,7 @@ class Over(ColumnElement): def __init__( self, element, partition_by=None, order_by=None, range_=None, rows=None ): - """Produce an :class:`.Over` object against a function. + r"""Produce an :class:`.Over` object against a function. Used against aggregate or so-called "window" functions, for database backends that support window functions. @@ -3253,11 +3262,13 @@ class Over(ColumnElement): mutually-exclusive parameters each accept a 2-tuple, which contains a combination of integers and None:: - func.row_number().over(order_by=my_table.c.some_column, range_=(None, 0)) + func.row_number().over( + order_by=my_table.c.some_column, range_=(None, 0)) The above would produce:: - ROW_NUMBER() OVER(ORDER BY some_column RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) + ROW_NUMBER() OVER(ORDER BY some_column + RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) A value of None indicates "unbounded", a value of zero indicates "current row", and negative / positive @@ -3290,7 +3301,7 @@ class Over(ColumnElement): :param order_by: a column element or string, or a list of such, that will be used as the ORDER BY clause of the OVER construct. - :param range_: optional range clause for the window. This is a + :param range\_: optional range clause for the window. This is a tuple value which can contain integer values or None, and will render a RANGE BETWEEN PRECEDING / FOLLOWING clause |