summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/operators.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-10-24 16:01:17 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-10-24 16:01:17 -0400
commitd0651ef4b3d27329166f25dfc060db1d86804c30 (patch)
treecd05f146fdb4d149cfdde1567479b8e9a07fa02a /lib/sqlalchemy/sql/operators.py
parent800c26e1b7549cc3d0b0e953b9821c411ecc5965 (diff)
downloadsqlalchemy-d0651ef4b3d27329166f25dfc060db1d86804c30.tar.gz
Added :meth:`.ColumnOperators.notin_`,
:meth:`.ColumnOperators.notlike`, :meth:`.ColumnOperators.notilike` to :class:`.ColumnOperators`. [ticket:2580]
Diffstat (limited to 'lib/sqlalchemy/sql/operators.py')
-rw-r--r--lib/sqlalchemy/sql/operators.py51
1 files changed, 48 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py
index 2e2ff3af1..8c5b9b3d5 100644
--- a/lib/sqlalchemy/sql/operators.py
+++ b/lib/sqlalchemy/sql/operators.py
@@ -368,6 +368,51 @@ class ColumnOperators(Operators):
"""
return self.operate(in_op, other)
+ def notin_(self, other):
+ """implement the ``NOT IN`` operator.
+
+ This is equivalent to using negation with :meth:`.ColumnOperators.in_`,
+ i.e. ``~x.in_(y)``.
+
+ .. versionadded:: 0.8
+
+ .. seealso::
+
+ :meth:`.ColumnOperators.in_`
+
+ """
+ return self.operate(notin_op, other)
+
+ def notlike(self, other, escape=None):
+ """implement the ``NOT LIKE`` operator.
+
+ This is equivalent to using negation with :meth:`.ColumnOperators.like`,
+ i.e. ``~x.like(y)``.
+
+ .. versionadded:: 0.8
+
+ .. seealso::
+
+ :meth:`.ColumnOperators.like`
+
+ """
+ return self.operate(notlike_op, other, escape=escape)
+
+ def notilike(self, other, escape=None):
+ """implement the ``NOT ILIKE`` operator.
+
+ This is equivalent to using negation with :meth:`.ColumnOperators.ilike`,
+ i.e. ``~x.ilike(y)``.
+
+ .. versionadded:: 0.8
+
+ .. seealso::
+
+ :meth:`.ColumnOperators.ilike`
+
+ """
+ return self.operate(notilike_op, other, escape=escape)
+
def is_(self, other):
"""Implement the ``IS`` operator.
@@ -583,13 +628,13 @@ def like_op(a, b, escape=None):
return a.like(b, escape=escape)
def notlike_op(a, b, escape=None):
- return ~a.like(b, escape=escape)
+ return a.notlike(b, escape=escape)
def ilike_op(a, b, escape=None):
return a.ilike(b, escape=escape)
def notilike_op(a, b, escape=None):
- return ~a.ilike(b, escape=escape)
+ return a.notilike(b, escape=escape)
def between_op(a, b, c):
return a.between(b, c)
@@ -598,7 +643,7 @@ def in_op(a, b):
return a.in_(b)
def notin_op(a, b):
- return ~a.in_(b)
+ return a.notin_(b)
def distinct_op(a):
return a.distinct()