[freeside-commits] freeside/FS/FS Record.pm,1.135.2.9,1.135.2.10
Ivan,,,
ivan at wavetail.420.am
Wed Jul 2 21:12:26 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv7325
Modified Files:
Tag: FREESIDE_1_7_BRANCH
Record.pm
Log Message:
this should non-"=" searches on fields that require SQL type binding...
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.135.2.9
retrieving revision 1.135.2.10
diff -u -d -r1.135.2.9 -r1.135.2.10
--- Record.pm 25 Jun 2008 00:29:31 -0000 1.135.2.9
+++ Record.pm 3 Jul 2008 04:12:24 -0000 1.135.2.10
@@ -376,10 +376,17 @@
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 } );
}
More information about the freeside-commits
mailing list