在下面的这个例子中:
my $rs = $schema->resultset('CD')->search(
{
'artist.name' => 'Bob Marley'
'liner_notes.notes' => { 'like', '%some text%' },
},
{
join => [qw/ artist liner_notes /],
order_by => [qw/ artist.name /],
}
);
DBIx食谱说这是将生成的 sql:
# Equivalent SQL:
# SELECT cd.*, artist.*, liner_notes.* FROM cd
# JOIN artist ON cd.artist = artist.id
# JOIN liner_notes ON cd.id = liner_notes.cd
# WHERE artist.name = 'Bob Marley'
# ORDER BY artist.name
但是从食谱的其余部分来看,我一直相信查询只会选择 cd.*,除非当然 prefetch 是这样使用的:
my $rs = $schema->resultset('CD')->search(
{
'artist.name' => 'Bob Marley'
'liner_notes.notes' => { 'like', '%some text%' },
},
{
join => [qw/ artist liner_notes /],
order_by => [qw/ artist.name /],
prefetch => [qw/ artist liner_notes/],
}
);
以下是让我相信这一点的陈述:
[Prefetch] allows you to fetch results from related tables in advance
谁能向我解释一下我在这里缺少什么?或不?非常感谢!