summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-03-09 08:23:30 +0100
committermkanat%kerio.com <>2005-03-09 08:23:30 +0100
commit5be75754f810eb414b666f3894e2dbf8943e3f0f (patch)
tree5c91e75fa2aaf9ad93e570396834d161b1aedfb1 /Bugzilla/DB
parent3f4abbd8d47883c52cdbd25ce308fe7d638f25ce (diff)
downloadbugzilla-5be75754f810eb414b666f3894e2dbf8943e3f0f.tar.gz
bugzilla-5be75754f810eb414b666f3894e2dbf8943e3f0f.tar.xz
Bug 281582: Replace CONCAT and MATCH with Bugzilla::DB function call (Note: This patch also creates a database-agnostic fulltext search method.)
Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=mkanat, a=myk
Diffstat (limited to 'Bugzilla/DB')
-rw-r--r--Bugzilla/DB/Mysql.pm14
-rw-r--r--Bugzilla/DB/Pg.pm11
2 files changed, 23 insertions, 2 deletions
diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm
index ae24d13bc..76cd0966d 100644
--- a/Bugzilla/DB/Mysql.pm
+++ b/Bugzilla/DB/Mysql.pm
@@ -88,7 +88,7 @@ sub sql_not_regexp {
}
sub sql_limit {
- my ($self, $limit,$offset) = @_;
+ my ($self, $limit, $offset) = @_;
if (defined($offset)) {
return "LIMIT $offset, $limit";
@@ -97,6 +97,18 @@ sub sql_limit {
}
}
+sub sql_string_concat {
+ my ($self, @params) = @_;
+
+ return 'CONCAT(' . join(', ', @params) . ')';
+}
+
+sub sql_fulltext_search {
+ my ($self, $column, $text) = @_;
+
+ return "MATCH($column) AGAINST($text)";
+}
+
sub sql_to_days {
my ($self, $date) = @_;
diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm
index 9766da383..5963f5308 100644
--- a/Bugzilla/DB/Pg.pm
+++ b/Bugzilla/DB/Pg.pm
@@ -93,7 +93,7 @@ sub sql_not_regexp {
}
sub sql_limit {
- my ($self, $limit,$offset) = @_;
+ my ($self, $limit, $offset) = @_;
if (defined($offset)) {
return "LIMIT $limit OFFSET $offset";
@@ -131,6 +131,15 @@ sub sql_interval {
return "INTERVAL '$interval'";
}
+sub sql_string_concat {
+ my ($self, @params) = @_;
+
+ # Postgres 7.3 does not support concatenating of different types, so we
+ # need to cast both parameters to text. Version 7.4 seems to handle this
+ # properly, so when we stop support 7.3, this can be removed.
+ return 'CAST(' . join(' AS text) || CAST(', @params) . ' AS text)';
+}
+
sub bz_lock_tables {
my ($self, @tables) = @_;