From 45bda63ed3da731cbde95396213ec92c68f734e3 Mon Sep 17 00:00:00 2001 From: Alexander Zayats Date: Thu, 18 Apr 2013 16:15:06 +0300 Subject: [PATCH] Adds Query.__rand__ and dal.Query.__ror__ Adds __rand__ == __and__ and __ror__ == __or__. Also strips trailing spaces. --- gluon/dal.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gluon/dal.py b/gluon/dal.py index 88ae5718..42019a0c 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -1255,7 +1255,7 @@ class BaseAdapter(ConnectionPool): return '(%s LIKE %s)' % (self.expand(first), self.expand('%'+second, 'string')) - def CONTAINS(self,first,second,case_sensitive=False): + def CONTAINS(self,first,second,case_sensitive=False): if first.type in ('string','text', 'json'): second = Expression(None,self.CONCAT('%',Expression( None,self.REPLACE(second,('%','%%'))),'%')) @@ -1306,7 +1306,7 @@ class BaseAdapter(ConnectionPool): ftype.startswith('decimal') def REPLACE(self, first, (second, third)): - return 'REPLACE(%s,%s,%s)' % (self.expand(first,'string'), + return 'REPLACE(%s,%s,%s)' % (self.expand(first,'string'), self.expand(second,'string'), self.expand(third,'string')) @@ -9578,9 +9578,13 @@ class Query(object): def __and__(self, other): return Query(self.db,self.db._adapter.AND,self,other) + __rand__ = __and__ + def __or__(self, other): return Query(self.db,self.db._adapter.OR,self,other) + __ror__ = __or__ + def __invert__(self): if self.op==self.db._adapter.NOT: return self.first