From: ivan Date: Sat, 1 Nov 2008 19:53:31 +0000 (+0000) Subject: backport bind_param fixes for DBD:Pg 1.x from 1.9, fixes "Cannot bind ... unknown... X-Git-Tag: freeside_1_7_4rc1~154 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=9d0fa42c1500bb5fa7e7f19d3271911240469bfc;p=freeside.git backport bind_param fixes for DBD:Pg 1.x from 1.9, fixes "Cannot bind ... unknown sql_type 6 on tax report, RT#4133 --- diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 31b0fe75f..ad6613e64 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -379,17 +379,22 @@ sub qsearch { my $value = $record->{$field}; #done above in 1.7# $value = $value->{'value'} if ref($value); my $type = dbdef->table($table)->column($field)->type; + + my $TYPE = SQL_VARCHAR; if ( $type =~ /(int|(big)?serial)/i && $value =~ /^\d+(\.\d+)?$/ ) { - $sth->bind_param($bind++, $value, { TYPE => SQL_INTEGER } ); + $TYPE = SQL_INTEGER; + + #DBD::Pg 1.49: Cannot bind ... unknown sql_type 6 with SQL_FLOAT } elsif ( ( $type =~ /(numeric)/i && $value =~ /^[+-]?\d+(\.\d+)?$/) || ( $type =~ /(real|float4)/i && $value =~ /[-+]?\d*\.?\d+([eE][-+]?\d+)?/ ) ) { - $sth->bind_param($bind++, $value, { TYPE => SQL_FLOAT } ); - } else { - $sth->bind_param($bind++, $value, { TYPE => SQL_VARCHAR } ); + $TYPE = SQL_DECIMAL; } + + $sth->bind_param($bind++, $value, { TYPE => $TYPE } ); + } # $sth->execute( map $record->{$_},