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()
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: text/plain
Charset: utf8
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 935
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.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Charset: utf8
Content-Type: text/plain
Message-ID: <rt-3.6.HEAD-6514-1258628542-1709.50839-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1234
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.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-2358-1288654899-1517.50839-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 85
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.