Subject: | incomplete use of $self->_bindtype when passing an ARRAYREF or ARRAYREFREF value to a column and bindtypes => 'columns' is in use |
Hi,
I was trying to make the following code work:
use SQL::Abstract;
use Data::Dumper;
my $sql = SQL::Abstract->new( bindtype => 'columns' );
my %data = (
name => 'Jimbo Bobson',
phone => '123-456-7890',
address => '42 Sister Lane',
city => 'St. Louis',
state => 'Louisiana',
blaz => \["to_date(?, 'MM/DD/YYYY')", "03/02/2003"]
);
my($stmt, @bind) = $sql->insert('people', \%data);
print "STMT ${stmt}\n";
print "BIND ".Dumper(@bind)."\n";
exit;
using SQL::Abstract version 1.61 on a
Linux 2.6.18-164.11.1.el5 #1 SMP Wed Jan 20 07:32:21 EST 2010 x86_64
x86_64 x86_64 GNU/Linux system with perl v5.8.8 built for
x86_64-linux-thread-multi.
I received the error :bindtype 'columns' selected, you need to pass:
[column_name => bind_value] at
/usr/lib/perl5/site_perl/5.8.8/SQL/Abstract.pm line 1108.
I manually edited Abstract.pm and determined that it needed to use the
$self->_bindtype function on each element in the @bind when the @bind is
passed in as an ARRAYREF or ARRAYREFREF. It now works correctly against
our Oracle database. I am not sure whether this works for all
databases, and all cases of passing in ARRAYREF(REF) values.
Here is the diff Abstract.pm.new Abstract.pm.orig
195d194
< @bind = map { $self->_bindtype($column, $_) } @bind;
204,205d202
< @bind = map { $self->_bindtype($column, $_) } @bind;
<
274d270
< @bind = map { $self->_bindtype($k, $_) } @bind;
1223d1218
< @bind = map { $self->_bindtype($k, $_) } @bind;
1230d1224
< @bind = map { $self->_bindtype($k, $_) } @bind;
I am happy to release this code for whatever use you deem appropriate.
Cheers,
Darin London