From 02a049703de6055f09f44f89a5a821814696ce32 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Thu, 7 Oct 2010 03:58:28 -0700 Subject: Bug 602165: Change sql_interval to sql_date_math, in preparation for MS-SQL and SQLite support. --- Bugzilla/DB/Mysql.pm | 6 +++--- Bugzilla/DB/Oracle.pm | 10 ++++++---- Bugzilla/DB/Pg.pm | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'Bugzilla/DB') diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm index 1829bc450..7b7e4e9b9 100644 --- a/Bugzilla/DB/Mysql.pm +++ b/Bugzilla/DB/Mysql.pm @@ -226,10 +226,10 @@ sub sql_date_format { return "DATE_FORMAT($date, " . $self->quote($format) . ")"; } -sub sql_interval { - my ($self, $interval, $units) = @_; +sub sql_date_math { + my ($self, $date, $operator, $interval, $units) = @_; - return "INTERVAL $interval $units"; + return "$date $operator INTERVAL $interval $units"; } sub sql_iposition { diff --git a/Bugzilla/DB/Oracle.pm b/Bugzilla/DB/Oracle.pm index a7ac6e93e..9fdacf24c 100644 --- a/Bugzilla/DB/Oracle.pm +++ b/Bugzilla/DB/Oracle.pm @@ -197,13 +197,15 @@ sub sql_date_format { return "TO_CHAR($date, " . $self->quote($format) . ")"; } -sub sql_interval { - my ($self, $interval, $units) = @_; +sub sql_date_math { + my ($self, $date, $operator, $interval, $units) = @_; + my $time_sql; if ($units =~ /YEAR|MONTH/i) { - return "NUMTOYMINTERVAL($interval,'$units')"; + $time_sql = "NUMTOYMINTERVAL($interval,'$units')"; } else{ - return "NUMTODSINTERVAL($interval,'$units')"; + $time_sql = "NUMTODSINTERVAL($interval,'$units')"; } + return "$date $operator $time_sql"; } sub sql_position { diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm index 0373fb1ce..c1c656a69 100644 --- a/Bugzilla/DB/Pg.pm +++ b/Bugzilla/DB/Pg.pm @@ -177,10 +177,10 @@ sub sql_date_format { return "TO_CHAR($date, " . $self->quote($format) . ")"; } -sub sql_interval { - my ($self, $interval, $units) = @_; +sub sql_date_math { + my ($self, $date, $operator, $interval, $units) = @_; - return "$interval * INTERVAL '1 $units'"; + return "$date $operator $interval * INTERVAL '1 $units'"; } sub sql_string_concat { -- cgit v1.2.3-24-g4f1b