jrsimmon has asked for the wisdom of the Perl Monks concerning the following question:
In the following code cut/paste out of Chart.pm from the DBIx::Chart package, it appears to me that the execute subroutine is incorrectly reversing the order of the arguments.
Ie:
becomes$dbh->execute($arg1, $arg2);
From DBIx::Chart:$dbh->execute($arg2, $arg1);
I tracked down this section of code when trying to understand why a query was returning undef from execute. The query received two arguments and they were being transposed, which resulted in the undef. Changing line 403 fromsub execute { my ($sth, @args) = @_; return $sth->SUPER::execute(@args) unless $sth->{private_dbix_chart_sth}; # # first execute each source sth, then execute the chart sth, # passing in the source sth's as a param, and picking up any # other placeholders we might need my @exec_parms; my $chartsth = $sth->{private_dbix_chart_sth}; my $src_sths = $chartsth->{_src_sths}; my $src_phs = $chartsth->{_src_phs}; my $chart_phs = $chartsth->{_chart_phs}; my $phcnt = $chartsth->{_chart_src_idx}; my $rc; foreach my $i (0..$#$src_sths) { @exec_parms = (); if (@args > 0) { push @exec_parms, $args[$_] #<--line 403 foreach (@{$src_phs->[$i]});
topush @exec_parms, $args[$_]
seems to fix my problem without any adverse affects. I wonder, though, whether it's truly this simple? Surely this code is used enough (I've seen references to DBIx::Chart all over the place) that I'm not the first to see this. Is there some purpose in transposing the arguments that I haven't been able to discern?unshift @exec_parms, $args[$_]
|
|---|