ResultSetColumn::func() now returns all results if called in list context
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / ResultSetColumn.pm
index f93cbdd..68cc4e0 100644 (file)
@@ -175,8 +175,13 @@ value. Produces the following SQL:
 
 sub func {
   my ($self,$function) = @_;
-  my ($row) = $self->{_parent_resultset}->search(undef, {select => {$function => $self->{_column}}, as => [$self->{_column}]})->cursor->next;
-  return $row;
+  my $cursor = $self->{_parent_resultset}->search(undef, {select => {$function => $self->{_column}}, as => [$self->{_column}]})->cursor;
+  
+  if( wantarray ) {
+    return map { $_->[ 0 ] } $cursor->all;
+  }
+
+  return ( $cursor->next )[ 0 ];
 }
 
 1;