From: Mike Bayer Date: Mon, 28 Jan 2013 18:49:18 +0000 (-0500) Subject: - documentation for any()/all() X-Git-Tag: rel_0_8_0~27^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c82e1cff7ae9047684676c863092c4659142f28;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - documentation for any()/all() --- diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index b17a7e7d17..bcdd77fa16 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -6,6 +6,15 @@ .. changelog:: :version: 0.8.0 + .. change:: + :tags: feature, postgresql + :pullreq: 40 + + Added :meth:`.postgresql.ARRAY.Comparator.any` and + :meth:`.postgresql.ARRAY.Comparator.all` + methods, as well as standalone expression constructs. Big thanks + to Audrius Kažukauskas for the terrific work here. + .. change:: :tags: sql, bug :tickets: 2643 diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index de150f03fe..a7a9e65ce1 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -366,12 +366,15 @@ class _Slice(expression.ColumnElement): class Any(expression.ColumnElement): - """Return the clause ``left operator ANY (right)``. ``right`` must be + """Represent the clause ``left operator ANY (right)``. ``right`` must be an array expression. - See also: + .. seealso:: + + :class:`.postgresql.ARRAY` + + :meth:`.postgresql.ARRAY.Comparator.any` - ARRAY-bound method - :class:`.postgresql.ARRAY` """ __visit_name__ = 'any' @@ -383,12 +386,15 @@ class Any(expression.ColumnElement): class All(expression.ColumnElement): - """Return the clause ``left operator ALL (right)``. ``right`` must be + """Represent the clause ``left operator ALL (right)``. ``right`` must be an array expression. - See also: + .. seealso:: + + :class:`.postgresql.ARRAY` + + :meth:`.postgresql.ARRAY.Comparator.all` - ARRAY-bound method - :class:`.postgresql.ARRAY` """ __visit_name__ = 'all' @@ -537,16 +543,62 @@ class ARRAY(sqltypes.Concatenable, sqltypes.TypeEngine): result_type=return_type) def any(self, other, operator=operators.eq): - """Return ``other operator ANY (array)`` clause. Argument places - are switched, because ANY requires array expression to be on the - right hand-side. + """Return ``other operator ANY (array)`` clause. + + Argument places are switched, because ANY requires array + expression to be on the right hand-side. + + E.g.:: + + from sqlalchemy.sql import operators + + conn.execute( + select([table.c.data]).where( + table.c.data.any(7, operator=operators.lt) + ) + ) + + :param other: expression to be compared + :param operator: an operator object from the + :mod:`sqlalchemy.sql.operators` + package, defaults to :func:`.operators.eq`. + + .. seealso:: + + :class:`.postgresql.Any` + + :meth:`.postgresql.ARRAY.Comparator.all` + """ return Any(other, self.expr, operator=operator) def all(self, other, operator=operators.eq): - """Return ``other operator ALL (array)`` clause. Argument places - are switched, because ALL requires array expression to be on the - right hand-side. + """Return ``other operator ALL (array)`` clause. + + Argument places are switched, because ALL requires array + expression to be on the right hand-side. + + E.g.:: + + from sqlalchemy.sql import operators + + conn.execute( + select([table.c.data]).where( + table.c.data.all(7, operator=operators.lt) + ) + ) + + :param other: expression to be compared + :param operator: an operator object from the + :mod:`sqlalchemy.sql.operators` + package, defaults to :func:`.operators.eq`. + + .. seealso:: + + :class:`.postgresql.All` + + :meth:`.postgresql.ARRAY.Comparator.any` + """ return All(other, self.expr, operator=operator)