[freeside-commits] freeside/FS/FS Record.pm,1.158,1.159
Ivan,,,
ivan at wavetail.420.am
Mon Jul 7 12:50:34 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv29925
Modified Files:
Record.pm
Log Message:
add debugging of bind_param statements
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -d -r1.158 -r1.159
--- Record.pm 3 Jul 2008 04:19:31 -0000 1.158
+++ Record.pm 7 Jul 2008 19:50:31 -0000 1.159
@@ -42,7 +42,7 @@
FS::UID->install_callback( sub {
eval "use FS::Conf;";
die $@ if $@;
- $conf = new FS::Conf;
+ $conf = FS::Conf->new;
$File::CounterFile::DEFAULT_DIR = $conf->base_dir . "/counters.". datasrc;
} );
@@ -238,6 +238,8 @@
=cut
+my %TYPE = (); #for debugging
+
sub qsearch {
my($stable, $record, $select, $extra_sql, $order_by, $cache, $addl_from );
my $debug = '';
@@ -298,20 +300,30 @@
foreach my $field (
grep defined( $record->{$_} ) && $record->{$_} ne '', @real_fields
) {
+
my $value = $record->{$field};
$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;
} 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_FLOAT;
}
+
+ if ( $DEBUG > 2 ) {
+ %TYPE = map { &{"DBI::$_"} => $_ } @{ $DBI::EXPORT_TAGS{sql_types} }
+ unless keys %TYPE;
+ warn " bind_param $bind (for field $field), $value, TYPE $TYPE{$TYPE}\n";
+ }
+
+ $sth->bind_param($bind++, $value, { TYPE => $TYPE } );
+
}
# $sth->execute( map $record->{$_},
More information about the freeside-commits
mailing list