From 7b4a0515becf3a6b7ffd145d7a1e00c11ede9b91 Mon Sep 17 00:00:00 2001 From: Massimo Date: Fri, 18 Jan 2013 09:14:19 -0600 Subject: [PATCH] fixed issue 1291, casting to string for like operator, thanks Dominic --- VERSION | 2 +- gluon/dal.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 3ba35bcf..45d8fe86 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.1-alpha.2+timestamp.2013.01.18.09.08.52 +Version 2.4.1-alpha.2+timestamp.2013.01.18.09.13.47 diff --git a/gluon/dal.py b/gluon/dal.py index b686d6f5..72a135fe 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -2570,12 +2570,18 @@ class PostgreSQLAdapter(BaseAdapter): def LIKE(self,first,second): - return '(%s LIKE %s)' % (self.expand(first), - self.expand(second,'string')) + args = (self.expand(first), self.expand(second,'string')) + if not first.type in ('string', 'text', 'json'): + return '(CAST(%s AS CHAR) LIKE %s)' % args + else: + return '(%s LIKE %s)' % args def ILIKE(self,first,second): - return '(%s ILIKE %s)' % (self.expand(first), - self.expand(second,'string')) + args = (self.expand(first), self.expand(second,'string')) + if not first.type in ('string', 'text', 'json'): + return '(CAST(%s AS CHAR) ILIKE %s)' % args + else: + return '(%s ILIKE %s)' % args def REGEXP(self,first,second): return '(%s ~ %s)' % (self.expand(first),