projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7688f9a
)
add debugging of bind_param statements
author
ivan
<ivan>
Mon, 7 Jul 2008 19:50:31 +0000
(19:50 +0000)
committer
ivan
<ivan>
Mon, 7 Jul 2008 19:50:31 +0000
(19:50 +0000)
FS/FS/Record.pm
patch
|
blob
|
history
diff --git
a/FS/FS/Record.pm
b/FS/FS/Record.pm
index
b9fb2ae
..
a27c4bc
100644
(file)
--- a/
FS/FS/Record.pm
+++ b/
FS/FS/Record.pm
@@
-42,7
+42,7
@@
my $rsa_decrypt;
FS::UID->install_callback( sub {
eval "use FS::Conf;";
die $@ if $@;
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;
} );
$File::CounterFile::DEFAULT_DIR = $conf->base_dir . "/counters.". datasrc;
} );
@@
-238,6
+238,8
@@
fine in the common case where there are only two parameters:
=cut
=cut
+my %TYPE = (); #for debugging
+
sub qsearch {
my($stable, $record, $select, $extra_sql, $order_by, $cache, $addl_from );
my $debug = '';
sub qsearch {
my($stable, $record, $select, $extra_sql, $order_by, $cache, $addl_from );
my $debug = '';
@@
-298,20
+300,30
@@
sub qsearch {
foreach my $field (
grep defined( $record->{$_} ) && $record->{$_} ne '', @real_fields
) {
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 $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+)?$/ ) {
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+)?/
)
) {
} 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->{$_},
}
# $sth->execute( map $record->{$_},