X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage.pm;h=7b7fa60e857d977aca32c1f1ee17c245128fc8b2;hb=38ed54cd3980bd344e13fad27ed11b935ae932aa;hp=bec0133bc34f9f59a5320c083b66a17225115413;hpb=9e34d55419481925691c7177d43ba48ec02b02eb;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage.pm b/lib/DBIx/Class/Storage.pm index bec0133..7b7fa60 100644 --- a/lib/DBIx/Class/Storage.pm +++ b/lib/DBIx/Class/Storage.pm @@ -187,7 +187,8 @@ transaction failure. =cut sub txn_do { - my ($self, $coderef, @args) = @_; + my $self = shift; + my $coderef = shift; ref $coderef eq 'CODE' or $self->throw_exception ('$coderef must be a CODE reference'); @@ -199,19 +200,21 @@ sub txn_do { my $wantarray = wantarray; # Need to save this since the context # inside the try{} block is independent # of the context that called txn_do() + my $args = \@_; + try { # Need to differentiate between scalar/list context to allow for # returning a list in scalar context to get the size of the list if ($wantarray) { # list context - @return_values = $coderef->(@args); + @return_values = $coderef->(@$args); } elsif (defined $wantarray) { # scalar context - $return_value = $coderef->(@args); + $return_value = $coderef->(@$args); } else { # void context - $coderef->(@args); + $coderef->(@$args); } $self->txn_commit; }