From: Alexander Hartmaier Date: Thu, 8 Aug 2013 08:07:51 +0000 (+0200) Subject: Improved docs for ResultSet columns attribute on how to retrieve related columns X-Git-Tag: v0.082800~164 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6dd8c7b6732363559bb33121f6acd2b0b96f1fe9;p=dbsrgits%2FDBIx-Class.git Improved docs for ResultSet columns attribute on how to retrieve related columns --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 8d96079..21fafff 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -3896,12 +3896,26 @@ earlier versions of DBIC, but this is deprecated) Essentially C does the same as L and L. - columns => [ 'foo', { bar => 'baz' } ] + columns => [ 'some_column', { dbic_slot => 'another_column' } ] is the same as - select => [qw/foo baz/], - as => [qw/foo bar/] + select => [qw(some_column another_column)], + as => [qw(some_column dbic_slot)] + +If you want to individually retrieve related columns (in essence perform +manual prefetch) you have to make sure to specify the correct inflation slot +chain such that it matches existing relationships: + + my $rs = $schema->resultset('Artist')->search({}, { + # required to tell DBIC to collapse has_many relationships + collapse => 1, + join => { cds => 'tracks'}, + '+columns' => { + 'cds.cdid' => 'cds.cdid', + 'cds.tracks.title' => 'tracks.title', + }, + }); =head2 +columns