diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-05-24 16:35:30 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-05-24 16:35:30 +0000 |
| commit | 4fc3a0648699c2b441251ba4e1d37a9107bd1986 (patch) | |
| tree | 5e02b768524d014ff5f355f58d6b15cbee7726a8 /lib/sqlalchemy | |
| parent | 5156d5141af04fe86ba317eadb73d8442eddc651 (diff) | |
| download | sqlalchemy-4fc3a0648699c2b441251ba4e1d37a9107bd1986.tar.gz | |
added explicit check for "==null()" to produce IS NULL, documnted "==None", "==null()", [ticket:187]
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/sql.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index fc0346b85..38866184f 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -549,17 +549,16 @@ class CompareMixin(object): def _bind_param(self, obj): return BindParamClause('literal', obj, shortname=None, type=self.type) def _compare(self, operator, obj): - if _is_literal(obj): - if obj is None: - 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") + if obj is None or isinstance(obj, Null): + if operator == '=': + return BooleanExpression(self._compare_self(), null(), 'IS') + elif operator == '!=': + return BooleanExpression(self._compare_self(), null(), 'IS NOT') return BooleanExpression(self._compare_self(), null(), 'IS') else: - obj = self._bind_param(obj) + raise exceptions.ArgumentError("Only '='/'!=' operators can be used with NULL") + elif _is_literal(obj): + obj = self._bind_param(obj) return BooleanExpression(self._compare_self(), obj, operator, type=self._compare_type(obj)) def _operate(self, operator, obj): if _is_literal(obj): |
