From: Ash Berlin Date: Fri, 22 May 2009 16:54:00 +0000 (+0000) Subject: Make distinct calculate columns *after* prefetch has been resolved. Tests to come X-Git-Tag: v0.08103~36 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=64d52da868b5e4ca33f439700304afa55170400f;p=dbsrgits%2FDBIx-Class.git Make distinct calculate columns *after* prefetch has been resolved. Tests to come --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index f6cc3ba..b48e7b4 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2608,8 +2608,6 @@ sub _resolved_attrs { } - $attrs->{group_by} ||= [ grep { !ref($_) || (ref($_) ne 'HASH') } @{$attrs->{select}} ] - if delete $attrs->{distinct}; if ( $attrs->{order_by} ) { $attrs->{order_by} = ( ref( $attrs->{order_by} ) eq 'ARRAY' @@ -2636,6 +2634,11 @@ sub _resolved_attrs { } push( @{ $attrs->{order_by} }, @pre_order ); } + + if (delete $attrs->{distinct}) { + $attrs->{group_by} ||= [ grep { !ref($_) || (ref($_) ne 'HASH') } @{$attrs->{select}} ]; + } + $attrs->{collapse} = $collapse; if ( $attrs->{page} and not defined $attrs->{offset} ) {