diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-06-08 17:29:18 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-06-08 17:29:18 +0000 |
commit | c133b136e14c9ad7023f396abbcdd109513407db (patch) | |
tree | 95a973e1a89e1ecc966157c9e51975233767b53c /lib/sqlalchemy/sql.py | |
parent | 2a79583ef42f793649f2597b190a3a69ab317172 (diff) | |
download | sqlalchemy-c133b136e14c9ad7023f396abbcdd109513407db.tar.gz |
fixed typing for between() operator, [ticket:202]
Diffstat (limited to 'lib/sqlalchemy/sql.py')
-rw-r--r-- | lib/sqlalchemy/sql.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index 2af45c6da..48c9f8754 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -551,7 +551,7 @@ class CompareMixin(object): def distinct(self): return CompoundClause(None,"DISTINCT", self) def between(self, cleft, cright): - return between_(self, cleft, cright) + return between_(self, self._check_literal(cleft), self._check_literal(cright)) def op(self, operator): return lambda other: self._compare(operator, other) # and here come the math operators: @@ -569,6 +569,11 @@ class CompareMixin(object): return self._operate('/', other) def _bind_param(self, obj): return BindParamClause('literal', obj, shortname=None, type=self.type) + def _check_literal(self, other): + if _is_literal(other): + return self._bind_param(other) + else: + return other def _compare(self, operator, obj): if obj is None or isinstance(obj, Null): if operator == '=': @@ -577,8 +582,8 @@ class CompareMixin(object): return BooleanExpression(self._compare_self(), null(), 'IS NOT') else: raise exceptions.ArgumentError("Only '='/'!=' operators can be used with NULL") - elif _is_literal(obj): - obj = self._bind_param(obj) + else: + obj = self._check_literal(obj) return BooleanExpression(self._compare_self(), obj, operator, type=self._compare_type(obj)) def _operate(self, operator, obj): |