Skip Menu |
 

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 50839
Status: resolved
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: ijw.bitcard [...] cack.org.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.08109
Fixed in: (no value)



Subject: Joining breaks query encapsulation of ->search()
Download (untitled) / with headers
text/plain 935b
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.
Download (untitled) / with headers
text/plain 1.2k
On Mon Oct 26 11:00:26 2009, ijw wrote: Show quoted text
> 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.
It was determined that DBIx::Class::Helper::VirtualView provides a viable short-term workaround. Stalling this ticket as a reminder on what needs to be fixed in the new join-resolution mechanism.
The as_subselect_rs method was merged into DBIx::Class::ResultSet from ::VirtualView.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.