Skip to content

Commit 6dd8c7b

Browse files
abraxxaribasushi
authored andcommitted
Improved docs for ResultSet columns attribute on how to retrieve related columns
1 parent 9a0dd97 commit 6dd8c7b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

lib/DBIx/Class/ResultSet.pm

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3896,12 +3896,26 @@ earlier versions of DBIC, but this is deprecated)
38963896
38973897
Essentially C<columns> does the same as L</select> and L</as>.
38983898
3899-
columns => [ 'foo', { bar => 'baz' } ]
3899+
columns => [ 'some_column', { dbic_slot => 'another_column' } ]
39003900
39013901
is the same as
39023902
3903-
select => [qw/foo baz/],
3904-
as => [qw/foo bar/]
3903+
select => [qw(some_column another_column)],
3904+
as => [qw(some_column dbic_slot)]
3905+
3906+
If you want to individually retrieve related columns (in essence perform
3907+
manual prefetch) you have to make sure to specify the correct inflation slot
3908+
chain such that it matches existing relationships:
3909+
3910+
my $rs = $schema->resultset('Artist')->search({}, {
3911+
# required to tell DBIC to collapse has_many relationships
3912+
collapse => 1,
3913+
join => { cds => 'tracks'},
3914+
'+columns' => {
3915+
'cds.cdid' => 'cds.cdid',
3916+
'cds.tracks.title' => 'tracks.title',
3917+
},
3918+
});
39053919
39063920
=head2 +columns
39073921

0 commit comments

Comments
 (0)