summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/elements.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-03-30 21:20:20 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-03-30 21:20:20 -0400
commite16ede8cae00fd5cbbd5fb33d63c14df0153c2bc (patch)
tree3116fa46093c735c59982600489b6d2a80c112fe /lib/sqlalchemy/sql/elements.py
parentefd3c311e0c62ae976733cf97e495a3c8ca76906 (diff)
downloadsqlalchemy-e16ede8cae00fd5cbbd5fb33d63c14df0153c2bc.tar.gz
- Added new flag :paramref:`.expression.between.symmetric`, when set to True
renders "BETWEEN SYMMETRIC". Also added a new negation operator "notbetween_op", which now allows an expression like ``~col.between(x, y)`` to render as "col NOT BETWEEN x AND y", rather than a parentheiszed NOT string. fixes #2990
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r--lib/sqlalchemy/sql/elements.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index c230fb0d3..5ebc7478a 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -45,7 +45,7 @@ def collate(expression, collation):
_literal_as_text(collation),
operators.collate, type_=expr.type)
-def between(expr, lower_bound, upper_bound):
+def between(expr, lower_bound, upper_bound, symmetric=False):
"""Produce a ``BETWEEN`` predicate clause.
E.g.::
@@ -85,13 +85,18 @@ def between(expr, lower_bound, upper_bound):
:param upper_bound: a column or Python scalar expression serving as the
upper bound of the right side of the ``BETWEEN`` expression.
+ :param symmetric: if True, will render " BETWEEN SYMMETRIC ". Note
+ that not all databases support this syntax.
+
+ .. versionadded:: 0.9.5
+
.. seealso::
:meth:`.ColumnElement.between`
"""
expr = _literal_as_binds(expr)
- return expr.between(lower_bound, upper_bound)
+ return expr.between(lower_bound, upper_bound, symmetric=symmetric)
def literal(value, type_=None):
"""Return a literal clause, bound to a bind parameter.