X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSet.pm;h=c6a68c3a9846761065895402c1751a4f6450ff9c;hb=0e7a447e570daf41c11b403fd81046756894cc27;hp=6dcbbf9ce13ebce12a8fb3457efce265aa447c4d;hpb=cf48da0c9ecff776e12d1f194c3be24b8079f1f4;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 6dcbbf9..c6a68c3 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -249,7 +249,17 @@ For more help on using joins with search, see L. sub search { my $self = shift; my $rs = $self->search_rs( @_ ); - return (wantarray ? $rs->all : $rs); + + my $want = wantarray; + if ($want) { + return $rs->all; + } + elsif (defined $want) { + return $rs; + } + else { + $self->throw_exception ('->search is *not* a mutator, calling it in void context makes no sense'); + } } =head2 search_rs @@ -1862,7 +1872,8 @@ my $mk_lazy_count_wizard = sub { # the tie class for 5.8.1 { - package DBIx::Class::__DBIC_LAZY_RS_COUNT__; + package # hide from pause + DBIx::Class::__DBIC_LAZY_RS_COUNT__; use base qw/Tie::Hash/; sub FIRSTKEY { my $dummy = scalar keys %{$_[0]{data}}; each %{$_[0]{data}} } @@ -3121,34 +3132,9 @@ sub _resolved_attrs { carp ("Useless use of distinct on a grouped resultset ('distinct' is ignored when a 'group_by' is present)"); } else { - my $storage = $self->result_source->schema->storage; - my $rs_column_list = $storage->_resolve_column_info ($attrs->{from}); - - my $group_spec = $attrs->{group_by} = []; - my %group_index; - - for (@{$attrs->{select}}) { - if (! ref($_) or ref ($_) ne 'HASH' ) { - push @$group_spec, $_; - $group_index{$_}++; - if ($rs_column_list->{$_} and $_ !~ /\./ ) { - # add a fully qualified version as well - $group_index{"$rs_column_list->{$_}{-source_alias}.$_"}++; - } - } - } - # add any order_by parts that are not already present in the group_by - # we need to be careful not to add any named functions/aggregates - # i.e. select => [ ... { count => 'foo', -as 'foocount' } ... ] - for my $chunk ($storage->_extract_order_columns($attrs->{order_by})) { - - # only consider real columns (for functions the user got to do an explicit group_by) - my $colinfo = $rs_column_list->{$chunk} - or next; - - $chunk = "$colinfo->{-source_alias}.$chunk" if $chunk !~ /\./; - push @$group_spec, $chunk unless $group_index{$chunk}++; - } + $attrs->{group_by} = $source->storage->_group_over_selection ( + @{$attrs}{qw/from select order_by/} + ); } }