# 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 {
my $self = shift;
return $self->result_source->resultset->search( undef, {
- alias => 'me',
+ alias => $self->current_source_alias,
from => [{
- me => $self->as_query,
+ $self->current_source_alias => $self->as_query,
-alias => $self->current_source_alias,
-source_handle => $self->result_source->handle,
}]