Old bug rising with a new head

"H.Merijn Brand" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
http://www.perlmonks.org/?node_id=910793

"You passed $nparm parameters where $n_req required"

Once was a correct fix. Then all moved from DBD::File to
DBI::DBD::SqlEngine and now SQL::Statement::Param roars its ugly head :)

I'd like to suggest the current fix, for which I am convinced is the
correct solution (unlit backends change again)

I do *not* have a testcase for this as I do not see the impact of
JOIN's and so here

--8<--- suggested change
diff --git a/lib/DBI/DBD/SqlEngine.pm b/lib/DBI/DBD/SqlEngine.pm
index 51f2a0a..bcac88a 100644
--- a/lib/DBI/DBD/SqlEngine.pm
+++ b/lib/DBI/DBD/SqlEngine.pm
@@ -781,7 +781,9 @@ sub execute
     {
         # bug in SQL::Statement 1.20 and below causes breakage
         # on all but the first call
-        unless ( ( my $req_prm = $stmt->params() ) == ( my $nparm = @$params ) )
+        my @req_prm = $stmt->params ();
+        my $n_req = @req_prm == 1 && ref $req_prm[0] ? $req_prm[0]->num : scalar @req_prm;
+        unless ( $n_req == ( my $nparm = @$params ) )
         {
             my $msg = "You passed $nparm parameters where $req_prm required";
             $sth->set_err( $DBI::stderr, $msg );
-->8---

-- 
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.14 and porting perl5.15.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.4 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.