]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- [bug] Added missing operators is_(), isnot()
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 22 Sep 2012 20:31:32 +0000 (16:31 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 22 Sep 2012 20:31:32 +0000 (16:31 -0400)
    to the ColumnOperators base, so that these long-available
    operators are present as methods like all
    the other operators.  [ticket:2544]

CHANGES
lib/sqlalchemy/sql/expression.py
lib/sqlalchemy/sql/operators.py

diff --git a/CHANGES b/CHANGES
index d3ef99689477b3a3f5105bc02601b87da2375abc..e16f995e3c12c9bfdd2f025e9f71e71bc842dd6b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -102,6 +102,11 @@ CHANGES
     here, so this has been re-instated and of
     course tested. [ticket:2558]
 
+  - [bug] Added missing operators is_(), isnot()
+    to the ColumnOperators base, so that these long-available
+    operators are present as methods like all
+    the other operators.  [ticket:2544]
+
 - engine
   - [bug] Fixed bug whereby
     a disconnect detect + dispose that occurs
index 3dec4bca89015f5c34bd43c86de01d1bc9ba84d5..0dd95b336958265c36863ea62a95c23f9687552d 100644 (file)
@@ -1910,7 +1910,8 @@ class _CompareMixin(ColumnOperators):
         operators.eq : (__compare, operators.ne),
         operators.like_op : (__compare, operators.notlike_op),
         operators.ilike_op : (__compare, operators.notilike_op),
-
+        operators.is_ : (__compare, operators.is_),
+        operators.isnot : (__compare, operators.isnot),
     }
 
     def operate(self, op, *other, **kwargs):
index 437358a1043a3ec882bf6314d3fa920fb92bcce1..32620bf90619f8a5be7e1e2e5586ad288f40146b 100644 (file)
@@ -284,6 +284,36 @@ class ColumnOperators(Operators):
         """
         return self.operate(in_op, other)
 
+    def is_(self, other):
+        """Implement the ``IS`` operator.
+
+        Normally, ``IS`` is generated automatically when comparing to a
+        value of ``None``, which resolves to ``NULL``.  However, explicit
+        usage of ``IS`` may be desirable if comparing to boolean values
+        on certain platforms.
+
+        .. versionadded:: 0.7.9
+
+        .. seealso:: :meth:`.ColumnOperators.isnot`
+
+        """
+        return self.operate(is_, other)
+
+    def isnot(self, other):
+        """Implement the ``IS NOT`` operator.
+
+        Normally, ``IS NOT`` is generated automatically when comparing to a
+        value of ``None``, which resolves to ``NULL``.  However, explicit
+        usage of ``IS NOT`` may be desirable if comparing to boolean values
+        on certain platforms.
+
+        .. versionadded:: 0.7.9
+
+        .. seealso:: :meth:`.ColumnOperators.is_`
+
+        """
+        return self.operate(isnot, other)
+
     def startswith(self, other, **kwargs):
         """Implement the ``startwith`` operator.