From: Frédéric Buclin Date: Mon, 1 Feb 2010 20:49:32 +0000 (-0800) Subject: Bug 533363: [PostgreSQL] Using "Bug ID contains foo" in boolean charts or "Exclude... X-Git-Tag: bugzilla-3.4.5~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=681be554d521ceff2584d02d184b81a6820aef01;p=thirdparty%2Fbugzilla.git 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 --- diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm index 18f9abf885..ce9b3ec5e0 100644 --- a/Bugzilla/DB/Pg.pm +++ b/Bugzilla/DB/Pg.pm @@ -94,13 +94,25 @@ sub bz_last_key { return $last_insert_id; } +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 { @@ -109,7 +121,7 @@ sub sql_not_regexp { $self->bz_check_regexp($real_pattern) if !$nocheck; - return "$expr !~* $pattern" + return "${expr}::text !~* $pattern" } sub sql_limit {