In questo esempio qui sotto:DBIx :: Class esempio
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 /],
}
);
Il DBIx cookbook dice che questa è la SQL che verrà generato:
# 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
Ma dal resto del libro di cucina, ho Sono stato portato a credere che la query avrebbe selezionato solo cd. *, a meno che ovviamente fosse usato prefetch in questo modo:
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/],
}
);
Di seguito è riportata la dichiarazione che mi porta a credere:
[Prefetch] allows you to fetch results from related tables in advance
Qualcuno può spiegarmi o cosa mi manca qui? O no? Molte grazie!
quindi nell'esempio sopra lo sql verrebbe modificato in "SELECT cd. *"? – srchulo
per l'equivalente sql: giusto – stevenl