summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-05-24 09:54:20 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-05-24 09:56:06 -0400
commit0e70d8ca7af1da400e4f8a88e3cc15ef181d0229 (patch)
tree6e9e662dc8e1b7ac0a05d6bc4d50dabd578c09c9
parent4fe31fe3c62968515ec1117ff13490cd0fc38bfc (diff)
downloadsqlalchemy-0e70d8ca7af1da400e4f8a88e3cc15ef181d0229.tar.gz
- hyperlink all the column operators listed in the ORM tutorial common filter operators section
- add language to MATCH explicitly stating this operator varies by backend and is not available on SQLite, as the tutorial defaults to SQLite to start with, fix #3059 - on the actual match() documentation fix this up to be more accurate, list some example renderings for different backends. again mention SQLite not supported
-rw-r--r--doc/build/orm/tutorial.rst26
-rw-r--r--lib/sqlalchemy/sql/operators.py14
2 files changed, 25 insertions, 15 deletions
diff --git a/doc/build/orm/tutorial.rst b/doc/build/orm/tutorial.rst
index 9a1050680..16d26ee24 100644
--- a/doc/build/orm/tutorial.rst
+++ b/doc/build/orm/tutorial.rst
@@ -744,19 +744,19 @@ Common Filter Operators
Here's a rundown of some of the most common operators used in
:func:`~sqlalchemy.orm.query.Query.filter`:
-* equals::
+* :meth:`equals <.ColumnOperators.__eq__>`::
query.filter(User.name == 'ed')
-* not equals::
+* :meth:`not equals <.ColumnOperators.__ne__>`::
query.filter(User.name != 'ed')
-* LIKE::
+* :meth:`LIKE <.ColumnOperators.like>`::
query.filter(User.name.like('%ed%'))
-* IN::
+* :meth:`IN <.ColumnOperators.in_>`::
query.filter(User.name.in_(['ed', 'wendy', 'jack']))
@@ -765,25 +765,25 @@ Here's a rundown of some of the most common operators used in
session.query(User.name).filter(User.name.like('%ed%'))
))
-* NOT IN::
+* :meth:`NOT IN <.ColumnOperators.notin_>`::
query.filter(~User.name.in_(['ed', 'wendy', 'jack']))
-* IS NULL::
+* :meth:`IS NULL <.ColumnOperators.is_>`::
query.filter(User.name == None)
# alternatively, if pep8/linters are a concern
query.filter(User.name.is_(None))
-* IS NOT NULL::
+* :meth:`IS NOT NULL <.ColumnOperators.isnot>`::
query.filter(User.name != None)
# alternatively, if pep8/linters are a concern
query.filter(User.name.isnot(None))
-* AND::
+* :func:`AND <.sql.expression.and_>`::
# use and_()
from sqlalchemy import and_
@@ -795,16 +795,20 @@ Here's a rundown of some of the most common operators used in
# or chain multiple filter()/filter_by() calls
query.filter(User.name == 'ed').filter(User.fullname == 'Ed Jones')
-* OR::
+* :func:`OR <.sql.expression.or_>`::
from sqlalchemy import or_
query.filter(or_(User.name == 'ed', User.name == 'wendy'))
-* match::
+* :meth:`MATCH <.ColumnOperators.match>`::
query.filter(User.name.match('wendy'))
- The contents of the match parameter are database backend specific.
+ .. note::
+
+ :meth:`~.ColumnOperators.match` uses a database-specific ``MATCH``
+ or ``CONTAINS`` function; its behavior will vary by backend and is not
+ available on some backends such as SQLite.
Returning Lists and Scalars
---------------------------
diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py
index 402610fa5..9ad30e49e 100644
--- a/lib/sqlalchemy/sql/operators.py
+++ b/lib/sqlalchemy/sql/operators.py
@@ -518,11 +518,17 @@ class ColumnOperators(Operators):
return self.operate(contains_op, other, **kwargs)
def match(self, other, **kwargs):
- """Implements the 'match' operator.
+ """Implements a database-specific 'match' operator.
- In a column context, this produces a MATCH clause, i.e.
- ``MATCH '<other>'``. The allowed contents of ``other``
- are database backend specific.
+ :meth:`~.ColumnOperators.match` attempts to resolve to
+ a MATCH-like function or operator provided by the backend.
+ Examples include:
+
+ * Postgresql - renders ``x @@ to_tsquery(y)``
+ * MySQL - renders ``MATCH (x) AGAINST (y IN BOOLEAN MODE)``
+ * Oracle - renders ``CONTAINS(x, y)``
+ * other backends may provide special implementations;
+ some backends such as SQLite have no support.
"""
return self.operate(match_op, other, **kwargs)