[Bast-commits] r7690 - DBIx-Class/0.08/trunk/lib/DBIx/Class
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Fri Sep 18 12:25:10 GMT 2009
Author: ribasushi
Date: 2009-09-18 12:25:06 +0000 (Fri, 18 Sep 2009)
New Revision: 7690
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSetColumn.pm
Log:
Minor cleanup of RSC with has_many joins
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSetColumn.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSetColumn.pm 2009-09-18 12:22:02 UTC (rev 7689)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSetColumn.pm 2009-09-18 12:25:06 UTC (rev 7690)
@@ -5,6 +5,7 @@
use base 'DBIx::Class';
+use Carp::Clan qw/^DBIx::Class/;
use DBIx::Class::Exception;
use List::Util;
@@ -65,7 +66,7 @@
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 @@
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;
More information about the Bast-commits
mailing list