Subject: | Arrays are not padded with undef. |
Date: | Mon, 06 Oct 2008 12:24:49 +1100 |
To: | bug-DBD-Pg [...] rt.cpan.org |
From: | Alex Cheshev <alex.cheshev [...] gmail.com> |
Hello.
#!/usr/bin/perl -w
use strict "vars";
use DBI;
my $dbh = DBI->connect("dbi:Pg:service=wed", "", "", { RaiseError => 1,
AutoCommit => 1 });
my @firsts = ("Alex", "Jack");
my @lasts = ("Cheshev", "Black", "White");
my $sth = $dbh->prepare("INSERT INTO test VALUES (?, ?)");
$sth->execute_array(undef, \@firsts, \@lasts);
$dbh->disconnect();
DBD::Pg::st execute_array failed: Arrayref for parameter 2 has 3
elements but parameter 1 has 2 at ./guestmanager.pl line 12.
DBD::Pg::st execute_array failed: Arrayref for parameter 2 has 3
elements but parameter 1 has 2 at ./guestmanager.pl line 12.
Array @firsts was not padded with undef but DBI says that:
Where column-wise binding is used (via the |@bind_values| argument or
calls to bind_param_array()) the maximum number of elements in any one
of the bound value arrays determines the number of tuples executed.
*Placeholders with fewer values in their parameter arrays are treated as
if padded with undef (NULL) values.*
I have to add $#lasts = $#firsts. It is so inconvenient.
Version of DBD::Pg is 2.9.0.