From 39af8fd0f459790feaf57d6f65075e823faa343d Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Mon, 1 Feb 2010 12:48:03 -0800 Subject: Bug 533363: [PostgreSQL] Using "Bug ID contains foo" in boolean charts or "Exclude bug numbered" charts crash PostgreSQL 8.3 and newer (non-character data types are no longer automatically cast to TEXT) Patch by Frédéric Buclin r/a=mkanat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/DB/Pg.pm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm index 585c0884b..b31d186bb 100644 --- a/Bugzilla/DB/Pg.pm +++ b/Bugzilla/DB/Pg.pm @@ -100,13 +100,25 @@ sub sql_group_concat { return "array_to_string(array_accum($text), $separator)"; } +sub sql_istring { + my ($self, $string) = @_; + + return "LOWER(${string}::text)"; +} + +sub sql_position { + my ($self, $fragment, $text) = @_; + + return "POSITION($fragment IN ${text}::text)"; +} + sub sql_regexp { my ($self, $expr, $pattern, $nocheck, $real_pattern) = @_; $real_pattern ||= $pattern; $self->bz_check_regexp($real_pattern) if !$nocheck; - return "$expr ~* $pattern"; + return "${expr}::text ~* $pattern"; } sub sql_not_regexp { @@ -115,7 +127,7 @@ sub sql_not_regexp { $self->bz_check_regexp($real_pattern) if !$nocheck; - return "$expr !~* $pattern" + return "${expr}::text !~* $pattern" } sub sql_limit { -- cgit v1.2.3-24-g4f1b