Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Why does DBIx::Chart reverse order of query args

by jrsimmon (Hermit)
on Jul 15, 2009 at 18:36 UTC ( #780429=perlquestion: print w/replies, xml ) Need Help??

jrsimmon has asked for the wisdom of the Perl Monks concerning the following question:

In the following code cut/paste out of from the DBIx::Chart package, it appears to me that the execute subroutine is incorrectly reversing the order of the arguments.

$dbh->execute($arg1, $arg2);
$dbh->execute($arg2, $arg1);

From DBIx::Chart:
sub 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]});
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 from
push @exec_parms, $args[$_]
unshift @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?

Update: Linkified the references to the cpan module

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://780429]
Approved by zwon
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2023-11-28 22:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found