clean up postgres-isms, RT#10324
authormark <mark>
Thu, 4 Nov 2010 05:57:00 +0000 (05:57 +0000)
committermark <mark>
Thu, 4 Nov 2010 05:57:00 +0000 (05:57 +0000)
FS/FS/cust_main/Search.pm
httemplate/search/svc_acct.cgi
rt/lib/RT/Tickets_Overlay.pm

index b9a30a5..ac170ff 100644 (file)
@@ -541,11 +541,13 @@ sub search {
       "cust_main.$field >= $beginning",
       "cust_main.$field <= $ending";
 
-    # XXX: do this for mysql and/or pull it out of here
     if(defined $hour) {
-      if ($dbh->{Driver}->{Name} eq 'Pg') {
+      if ($dbh->{Driver}->{Name} =~ /Pg/i) {
         push @where, "extract(hour from to_timestamp(cust_main.$field)) = $hour";
       }
+      elsif( $dbh->{Driver}->{Name} =~ /mysql/i) {
+        push @where, "hour(from_unixtime(cust_main.$field)) = $hour"
+      }
       else {
         warn "search by time of day not supported on ".$dbh->{Driver}->{Name}." databases";
       }
index 1407d9e..c3ddd66 100755 (executable)
@@ -262,13 +262,13 @@ if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) {
   }
 
   $cgi->param('username') =~ /^([\w\-\.\&]+)$/; #untaint username_text
-  my $username = $1;
+  my $username = lc($1);
 
-  push @username_sql, "username ILIKE '$username'"
+  push @username_sql, "LOWER(username) LIKE '$username'"
     if $username_type{'Exact'}
     || $username_type{'Fuzzy'};
 
-  push @username_sql, "username ILIKE '\%$username\%'"
+  push @username_sql, "LOWER(username) LIKE '\%$username\%'"
     if $username_type{'Substring'}
     || $username_type{'All'};
 
index f2949ed..be5a0d5 100644 (file)
@@ -1855,7 +1855,13 @@ sub OrderByCols {
            );
 
            #if there was a Links.RemoteTarget int, this bs wouldn't be necessary
-           my $custnum_sql = "CAST(SUBSTR($linkalias.Target,31) AS INTEGER)";
+           my $custnum_sql = "CAST(SUBSTR($linkalias.Target,31) AS ";
+           if ( RT->Config->Get('DatabaseType') eq 'mysql' ) {
+             $custnum_sql .= 'SIGNED INTEGER)';
+           }
+           else {
+             $custnum_sql .= 'INTEGER)';
+           }
 
            if ( $subkey eq 'Number' ) {