From: ivan Date: Thu, 3 Jul 2008 04:12:24 +0000 (+0000) Subject: this should non-"=" searches on fields that require SQL type binding... X-Git-Tag: freeside_1_7_4rc1~260 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=72bd7aaecbb9bad5d6e0038997423ff2be7e93b2;p=freeside.git this should non-"=" searches on fields that require SQL type binding... --- diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 932c63426..d3b5e183e 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -376,10 +376,17 @@ sub qsearch { foreach my $field ( grep defined( $record->{$_} ) && $record->{$_} ne '', @real_fields ) { - if ( $record->{$field} =~ /^\d+(\.\d+)?$/ - && dbdef->table($table)->column($field)->type =~ /(int|(big)?serial)/i - ) { + my $value = $record->{$field}; + $value = $value->{'value'} if ref($value); + my $type = dbdef->table($table)->column($field)->type; + if ( $type =~ /(int|(big)?serial)/i && $value =~ /^\d+(\.\d+)?$/ ) { $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_INTEGER } ); + } elsif ( ( $type =~ /(numeric)/i && $value =~ /^[+-]?\d+(\.\d+)?$/) + || ( $type =~ /(real|float4)/i + && $value =~ /[-+]?\d*\.?\d+([eE][-+]?\d+)?/ + ) + ) { + $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_FLOAT } ); } else { $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_VARCHAR } ); }