diff options
author | ivan <ivan> | 2008-07-03 03:57:16 +0000 |
---|---|---|
committer | ivan <ivan> | 2008-07-03 03:57:16 +0000 |
commit | 9dc7702002fc9567749997e84a276d596ec8262b (patch) | |
tree | be5b164db1221d61d2bd0cb70518caff4feb2b45 /FS | |
parent | 9099272c0d3fa55ddcb9e0f8f42c93bb79a83fdc (diff) |
real should be bound to SQL_FLOAT Like float4... 1.7? not touching it unless it breaks :)
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Record.pm | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index cd54b849f..d085354ed 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -298,17 +298,15 @@ 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}; + 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 ( $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 - ) { + } 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 } ); |