]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added != support for None -> foo IS NOT NULL
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 12 May 2006 17:11:46 +0000 (17:11 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 12 May 2006 17:11:46 +0000 (17:11 +0000)
lib/sqlalchemy/sql.py

index 8c10a44d942cecf060701ed5441d0f49e625e9f2..5edfe6f1faa9ad69ff894867ba59b9a5549a0f53 100644 (file)
@@ -540,8 +540,12 @@ class CompareMixin(object):
     def _compare(self, operator, obj):
         if _is_literal(obj):
             if obj is None:
-                if operator != '=':
-                    raise ArgumentError("Only '=' operator can be used with NULL")
+                if operator == '=':
+                    return BooleanExpression(self._compare_self(), null(), 'IS')
+                elif operator == '!=':
+                    return BooleanExpression(self._compare_self(), null(), 'IS NOT')
+                else:
+                    raise exceptions.ArgumentError("Only '='/'!=' operators can be used with NULL")
                 return BooleanExpression(self._compare_self(), null(), 'IS')
             else:
                 obj = self._bind_param(obj)