Propagate the results out of the 'row' function correctly again -- the wantarray context isn't maintained inside a try block, unfortunately

This commit is contained in:
ian%hixie.ch 2002-12-28 03:27:23 +00:00
Родитель c30ca82777
Коммит ac03050fbd
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -59,8 +59,9 @@ sub rowsAffected {
sub row { sub row {
my $self = shift; my $self = shift;
$self->assert($self->executed, 1, 'Tried to fetch data from an unexecuted statement'); $self->assert($self->executed, 1, 'Tried to fetch data from an unexecuted statement');
my $wantarray = wantarray; # to propagate it into the try block below
my @result = try { my @result = try {
if (wantarray) { if ($wantarray) {
return $self->handle->fetchrow_array(); return $self->handle->fetchrow_array();
} else { } else {
my $array = $self->handle->fetchrow_arrayref(); my $array = $self->handle->fetchrow_arrayref();
@ -84,7 +85,7 @@ sub row {
raise $exception; raise $exception;
} }
}; };
return @result; return $wantarray ? @result : $result[0];
} }
sub rows { sub rows {