use base 'DBIx::Class';
use DBIx::Class::Carp;
-use DBIx::Class::Exception;
# not importing first() as it will clash with our own method
use List::Util ();
if ($colmap->{$select} and $rsrc->_identifying_column_set([$colmap->{$select}])) {
$new_attrs->{group_by} = [ $select ];
- delete $new_attrs->{distinct}; # it is ignored when group_by is present
+ delete @{$new_attrs}{qw(distinct _grouped_by_distinct)}; # it is ignored when group_by is present
}
else {
carp (
=item Arguments: none
-=item Return Value: \[ $sql, @bind ]
+=item Return Value: \[ $sql, L<@bind_values|DBIx::Class::ResultSet/DBIC BIND VALUES> ]
=back
there are none).
Much like L<DBIx::Class::ResultSet/all> but returns values rather
-than row objects.
+than result objects.
=cut
=item Arguments: none
-=item Return Value: $resultset
+=item Return Value: L<$resultset|DBIx::Class::ResultSet>
=back
=item Arguments: none
-=item Return Value: $resultset
+=item Return Value: L<$resultset|DBIx::Class::ResultSet>
=back
=item Arguments: none
-=item Return Value: $resultset
+=item Return Value: L<$resultset|DBIx::Class::ResultSet>
=back
=item Arguments: $function
-=item Return Value: $resultset
+=item Return Value: L<$resultset|DBIx::Class::ResultSet>
=back
sub func_rs {
my ($self,$function) = @_;
- return $self->{_parent_resultset}->search(
- undef, {
- select => {$function => $self->{_select}},
- as => [$self->{_as}],
- },
- );
+
+ my $rs = $self->{_parent_resultset};
+ my $select = $self->{_select};
+
+ # wrap a grouped rs
+ if ($rs->_resolved_attrs->{group_by}) {
+ $select = $self->{_as};
+ $rs = $rs->as_subselect_rs;
+ }
+
+ $rs->search( undef, {
+ columns => { $self->{_as} => { $function => $select } }
+ } );
}
=head2 throw_exception
=cut
sub throw_exception {
- my $self=shift;
+ my $self = shift;
if (ref $self && $self->{_parent_resultset}) {
$self->{_parent_resultset}->throw_exception(@_);
1;
-=head1 AUTHORS
-
-Luke Saunders <luke.saunders@gmail.com>
+=head1 AUTHOR AND CONTRIBUTORS
-Jess Robinson
+See L<AUTHOR|DBIx::Class/AUTHOR> and L<CONTRIBUTORS|DBIx::Class/CONTRIBUTORS> in DBIx::Class
=head1 LICENSE