note that group_by takes listref rather than list + provide example
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / ResultSet.pm
index ae6fb3e..38efc79 100644 (file)
@@ -40,6 +40,20 @@ sub new {
   #use Data::Dumper; warn Dumper($attrs);
   $attrs = Storable::dclone($attrs || {}); # { %{ $attrs || {} } };
   my %seen;
+
+  # wrong! we cannot delete select/as because it will interfere with the count() method. need to just set alias correctly in the first instance
+=pod
+  if( $attrs->{from} && $attrs->{alias} eq 'me' ) {
+    my @keys = keys( %{$attrs->{from}->[0]} );
+    $attrs->{alias} = $keys[0];
+    delete $attrs->{select};
+    delete $attrs->{as};
+    #die Dumper $attrs;
+  }
+=cut
+# alias should be set in accordance with from if alias is not defined or = "me"
+# could also alter the line below instead, i.e. use alias if defined, then get from "from", then class->table, then "me" as a last resort.
+
   my $alias = ($attrs->{alias} ||= 'me');
   if (!$attrs->{select}) {
     my @cols = ($attrs->{cols}
@@ -541,11 +555,13 @@ for an unpaged resultset.
 
 For a paged resultset, how many rows per page
 
-=head2 group_by
+=head2 group_by (listref)
 
-A list of columns to group by (note that 'count' doesn't work on grouped
+A listref of columns to group by (note that 'count' doesn't work on grouped
 resultsets)
 
+  group_by => [qw/ column1 column2 ... /]
+
 =head2 distinct
 
 Set to 1 to group by all columns