X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSetColumn.pm;h=430e35b4efbfc91621dd2f9f8c83fbbfbdc6fbc1;hb=26283ee38f220f6c6bae720ea5a189c9c0f47f6f;hp=bdb86520e3bcdfe4a848d34384af6e2473ef7563;hpb=1a58752c42ba9acf33e2943b678de4948cf3ee3f;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSetColumn.pm b/lib/DBIx/Class/ResultSetColumn.pm index bdb8652..430e35b 100644 --- a/lib/DBIx/Class/ResultSetColumn.pm +++ b/lib/DBIx/Class/ResultSetColumn.pm @@ -5,6 +5,7 @@ use warnings; use base 'DBIx::Class'; +use Carp::Clan qw/^DBIx::Class/; use DBIx::Class::Exception; use List::Util; @@ -65,7 +66,7 @@ sub new { my $select = defined $as_index ? $select_list->[$as_index] : $column; # {collapse} would mean a has_many join was injected, which in turn means - # we need to group IF WE CAN (only if the column in question is unique) + # we need to group *IF WE CAN* (only if the column in question is unique) if (!$new_attrs->{group_by} && keys %{$orig_attrs->{collapse}}) { # scan for a constraint that would contain our column only - that'd be proof @@ -80,9 +81,17 @@ sub new { if ($col eq $select or $fqcol eq $select) { $new_attrs->{group_by} = [ $select ]; + delete $new_attrs->{distinct}; # it is ignored when group_by is present last; } } + + if (!$new_attrs->{group_by}) { + carp ( + "Attempting to retrieve non-unique column '$column' on a resultset containing " + . 'one-to-many joins will return duplicate results.' + ); + } } my $new = bless { _select => $select, _as => $column, _parent_resultset => $new_parent_rs }, $class;