on-demand vs. automatic cards & checks: added DCRD and DCHK payment types
[freeside.git] / FS / FS / Record.pm
index ebcbbb4..c711f12 100644 (file)
@@ -223,13 +223,21 @@ sub qsearch {
       if ( ! defined( $record->{$_} ) || $record->{$_} eq '' ) {
         if ( $op eq '=' ) {
           if ( driver_name eq 'Pg' ) {
-            qq-( $column IS NULL OR $column = '' )-;
+            if ( $dbdef->table($table)->column($column)->type =~ /(int)/i ) {
+              qq-( $column IS NULL )-;
+            } else {
+              qq-( $column IS NULL OR $column = '' )-;
+            }
           } else {
             qq-( $column IS NULL OR $column = "" )-;
           }
         } elsif ( $op eq '!=' ) {
           if ( driver_name eq 'Pg' ) {
-            qq-( $column IS NOT NULL AND $column != '' )-;
+            if ( $dbdef->table($table)->column($column)->type =~ /(int)/i ) {
+              qq-( $column IS NOT NULL )-;
+            } else {
+              qq-( $column IS NOT NULL AND $column != '' )-;
+            }
           } else {
             qq-( $column IS NOT NULL AND $column != "" )-;
           }
@@ -330,9 +338,11 @@ for a single item, or your data is corrupted.
 =cut
 
 sub qsearchs { # $result_record = &FS::Record:qsearchs('table',\%hash);
+  my $table = $_[0];
   my(@result) = qsearch(@_);
-  carp "warning: Multiple records in scalar search!" if scalar(@result) > 1;
-    #should warn more vehemently if the search was on a primary key?
+  carp "warning: Multiple records in scalar search ($table)"
+    if scalar(@result) > 1;
+  #should warn more vehemently if the search was on a primary key?
   scalar(@result) ? ($result[0]) : ();
 }