Subject: | Joining breaks query encapsulation of ->search() |
Using 'artists' and 'cds' I might do:
my $artists_with_best_of = $artists->search(
{ 'cds.name' => 'best of' },
{ join => 'cds' });
to describe a resultset 'all artists with a best of CD'. This is a nice
encapsulated resultset which I should be able to treat in other search
expressions as 'a subset of all artists'.
Similarly, I can do:
my $artists_with_great_cds = $artists->search(
{ 'cds.sales' => { '>', 100000 },
{ join => 'cds' });
to find artists with high-selling CDs.
But what I can't do is:
my $some_artists_with_great_cds = $artist_with_best_of->search(
{ 'cds.sales' => { '>', 100000 },
{ join => 'cds' });
... because DBIC auto-aliases the second join to 'cds_2', but the query
being constructed is not aware that this is happening.
I want to be able to write functions to filter an arbitrary resultset
using whatever joins I feel like, but the problem above prevents that
from working.