From: Mike Bayer Date: Thu, 19 Jul 2007 07:21:50 +0000 (+0000) Subject: fixed LIKE/BEWTEEN operators X-Git-Tag: rel_0_4_6~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06486580c36b0db3f1797a46e98d121e20d0c132;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git fixed LIKE/BEWTEEN operators --- diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index 672d085487..8c5f171ea9 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -1365,9 +1365,9 @@ class _CompareMixin(ColumnOperators): def startswith(self, other): """produce the clause ``LIKE '%'``""" - + perc = isinstance(other,(str,unicode)) and '%' or literal('%',type_= sqltypes.String) - return self.__compare('LIKE', other + perc) + return self.__compare(ColumnOperators.like_op, other + perc) def endswith(self, other): """produce the clause ``LIKE '%'``""" @@ -1376,7 +1376,7 @@ class _CompareMixin(ColumnOperators): else: po = literal('%', type_=sqltypes.String) + other po.type = sqltypes.to_instance(sqltypes.String) #force! - return self.__compare('LIKE', po) + return self.__compare(ColumnOperators.like_op, po) def label(self, name): """produce a column label, i.e. `` AS ``""" @@ -1388,7 +1388,8 @@ class _CompareMixin(ColumnOperators): def between(self, cleft, cright): """produce a BETWEEN clause, i.e. `` BETWEEN AND ``""" - return _BinaryExpression(self, ClauseList(self._check_literal(cleft), self._check_literal(cright), operator=operator.and_, group=False), 'BETWEEN') + + return _BinaryExpression(self, ClauseList(self._check_literal(cleft), self._check_literal(cright), operator=operator.and_, group=False), ColumnOperators.between_op) def op(self, operator): """produce a generic operator function.