以下のこの例では:
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。*のみを選択すると信じるようになりました。
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
私がここで欠けているものを誰かが私に説明できますか?か否か?どうもありがとう!