From: Arthur Axel "fREW" Schmidt Date: Mon, 8 Feb 2010 05:17:43 +0000 (+0000) Subject: another example of as_subselect_rs X-Git-Tag: v0.08118~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bc64456d2ebecc3ed8f8ab7db641ff0af0c7db39;p=dbsrgits%2FDBIx-Class.git another example of as_subselect_rs --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index df82fcf..3677225 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2623,6 +2623,18 @@ it were simply where-filtered without joins). For example: # works as expected: finds a 'table' row related to two x rows (abc and def) my $correctly_joined_rs = $rs2->search({'x.name' => 'def'}); +Another example of when one might use this would be to select a subset of +columns in a group by clause: + + my $rs = $schema->resultset('Bar')->search(undef, { + group_by => [qw{ id foo_id baz_id }], + })->as_subselect_rs->search(undef, { + columns => [qw{ id foo_id }] + }); + +In the above example normally columns would have to be equal to the group by, +but because we isolated the group by into a subselect the above works. + =cut sub as_subselect_rs {