Author: hmbrand Date: Thu Jun 23 00:57:10 2011 New Revision: 14891 Modified: dbi/trunk/Changes dbi/trunk/lib/DBI/DBD/SqlEngine.pm
Log: Fixed parameter-count check for complicated statements using DBI::DBD::SqlEngine When the params are in SQL::Statement::Param form, you cannot just count the entries in the list, but need to access the num method on the first (and only) entry in the list. Now this fix only covered a test case where the number of params was NIL and I don't know if it is possible that the count is higher, and if so, if the test is still correct in those cases. This fix needs tests! See http://www.perlmonks.org/?node_id=910793 for an in-detail discussion Signed-off-by: H.Merijn Brand (Tux) <[email protected]> Modified: dbi/trunk/Changes ============================================================================== --- dbi/trunk/Changes (original) +++ dbi/trunk/Changes Thu Jun 23 00:57:10 2011 @@ -13,6 +13,8 @@ Fixed the definition of ArrayTupleStatus and remove confusion over rows affected in list context of execute_array (Martin J. Evans) Fixed sql_type_cast example and typo in errors (Martin J. Evans) + Fixed parameter-count check for complicated statements using + DBI::DBD::SqlEngine + SQL::Statement::Param (H.Merijn Brand) Enhanced and standardized driver trace level mechanism (Tim Bunce) Removed old code that was an inneffective attempt to detect Modified: dbi/trunk/lib/DBI/DBD/SqlEngine.pm ============================================================================== --- dbi/trunk/lib/DBI/DBD/SqlEngine.pm (original) +++ dbi/trunk/lib/DBI/DBD/SqlEngine.pm Thu Jun 23 00:57:10 2011 @@ -781,7 +781,9 @@ { # 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 );
