From e4c7cd8602ebb3e70895aee1d7d8a49371ccb70c Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Feb 2009 01:50:56 +0000 Subject: [PATCH] fix "improved" float searching problems, RT#4878 --- FS/FS/Record.pm | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 2d70206f2..cb0918068 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -320,6 +320,7 @@ sub qsearch { ) { my $value = $record->{$field}; + my $op = (ref($value) && $value->{op}) ? $value->{op} : '='; $value = $value->{'value'} if ref($value); my $type = dbdef->table($table)->column($field)->type; @@ -329,6 +330,7 @@ sub qsearch { #DBD::Pg 1.49: Cannot bind ... unknown sql_type 6 with SQL_FLOAT #fixed by DBD::Pg 2.11.8 + #can change back to SQL_FLOAT in early-mid 2010, once everyone's upgraded } elsif ( _is_fs_float( $type, $value ) ) { $TYPE = SQL_DECIMAL; } @@ -340,13 +342,16 @@ sub qsearch { warn " bind_param $bind (for field $field), $value, TYPE $TYPE{$TYPE}\n"; } - if ($TYPE eq SQL_DECIMAL) { - # these values are arbitrary; better (faster?) ones welcome - $sth->bind_param($bind++, $value*1.00001, { TYPE => $TYPE } ); - $sth->bind_param($bind++, $value*.99999, { TYPE => $TYPE } ); - }else{ + #if this needs to be re-enabled, it needs to use a custom op like + #"APPROX=" or something (better name?, not '=', to avoid affecting other + # searches + #if ($TYPE eq SQL_DECIMAL && $op eq 'APPROX=' ) { + # # these values are arbitrary; better (faster?) ones welcome + # $sth->bind_param($bind++, $value*1.00001, { TYPE => $TYPE } ); + # $sth->bind_param($bind++, $value*.99999, { TYPE => $TYPE } ); + #} else { $sth->bind_param($bind++, $value, { TYPE => $TYPE } ); - } + #} } @@ -536,8 +541,11 @@ sub get_real_fields { qq-( $column $op "" )-; } } - } elsif ( $op eq '=' && _is_fs_float( $type, $value ) ) { - ( "$column <= ?", "$column >= ?" ); + #if this needs to be re-enabled, it needs to use a custom op like + #"APPROX=" or something (better name?, not '=', to avoid affecting other + # searches + #} elsif ( $op eq 'APPROX=' && _is_fs_float( $type, $value ) ) { + # ( "$column <= ?", "$column >= ?" ); } else { "$column $op ?"; } -- 2.11.0