- When adding relationships, it will throw an exception if you get the
foreign and self parts the wrong way round in the condition
+ - ResultSetColumn::func() now returns all results if called in list
+ context; this makes things like func('DISTINCT') work as expected
0.08007 2007-09-04 19:36:00
- patch for Oracle datetime inflation (abram@arin.net)
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;
my $schema = DBICTest->init_schema();
-plan tests => 9;
+plan tests => 10;
my $cd;
my $rs = $cd = $schema->resultset("CD")->search({});
is($rs_title->next, 'Spoonful of bees', "next okay");
+is_deeply( [ sort $rs_year->func('DISTINCT') ], [ 1997, 1998, 1999, 2001 ], "wantarray context okay");
+
my @all = $rs_title->all;
cmp_ok(scalar @all, '==', 5, "five titles returned");