summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/expression.py3
-rw-r--r--lib/sqlalchemy/sql/operators.py51
2 files changed, 51 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index 5b6e4d82d..1681b26f4 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -2097,6 +2097,8 @@ class _DefaultColumnComparator(operators.ColumnOperators):
"eq": (_boolean_compare, operators.ne),
"like_op": (_boolean_compare, operators.notlike_op),
"ilike_op": (_boolean_compare, operators.notilike_op),
+ "notlike_op": (_boolean_compare, operators.like_op),
+ "notilike_op": (_boolean_compare, operators.ilike_op),
"contains_op": (_boolean_compare, operators.notcontains_op),
"startswith_op": (_boolean_compare, operators.notstartswith_op),
"endswith_op": (_boolean_compare, operators.notendswith_op),
@@ -2105,6 +2107,7 @@ class _DefaultColumnComparator(operators.ColumnOperators):
"nullsfirst_op": (_scalar, nullsfirst),
"nullslast_op": (_scalar, nullslast),
"in_op": (_in_impl, operators.notin_op),
+ "notin_op": (_in_impl, operators.in_op),
"is_": (_boolean_compare, operators.is_),
"isnot": (_boolean_compare, operators.isnot),
"collate": (_collate_impl,),
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()