I'm struggling with fairly fundamental DBIx-Class prefetch usage. I want to limit the columns that are returned from joined tables when prefetch is used.
This:
my $rs = $schema->resultset('CD')->search(
{}, # No searching restrictions through WHERE clause
{
prefetch => [qw/ artist /],
columns => [qw/ title artist.name /],
}
);
Generates this SQL:
SELECT cd.title, artist.*
FROM cd
JOIN artist ON cd.artist = artist.id
But I don't want to haul down all of the artist columns, just the cd.title and artist.name columns (in this example, my real use case is more complex). The columns feature seems to only work on the primary table rather than than joined tables as well.
I'd like this SQL:
SELECT cd.title, artist.name
FROM cd
JOIN artist ON cd.artist = artist.id
I'm just getting my sea-legs with Catalyst/DBIx-Class so I'm probably over-looking something blindingly obvious here!