Improve record searching
authorjeff <jeff>
Mon, 14 Apr 2008 13:42:25 +0000 (13:42 +0000)
committerjeff <jeff>
Mon, 14 Apr 2008 13:42:25 +0000 (13:42 +0000)
FS/FS/Record.pm

index db94003..d010f86 100644 (file)
@@ -298,6 +298,14 @@ sub qsearch {
          && dbdef->table($table)->column($field)->type =~ /(int|(big)?serial)/i
     ) {
       $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_INTEGER } );
+    }elsif ( $record->{$field} =~ /^[+-]?\d+(\.\d+)?$/
+         && dbdef->table($table)->column($field)->type =~ /(numeric)/i
+    ) {
+      $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_FLOAT } );
+    }elsif ( $record->{$field} =~ /[-+]?\d*\.?\d+([eE][-+]?\d+)?/
+         && dbdef->table($table)->column($field)->type =~ /(float4)/i
+    ) {
+      $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_FLOAT } );
     } else {
       $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_VARCHAR } );
     }