[Dbix-class] "search on row->has_many fails if row has prefetch
join" after 0.08196 -> 0.08206 upgrade
Chisel
chisel at chizography.net
Fri Feb 22 17:55:39 GMT 2013
On Fri, Feb 22, 2013 at 4:58 PM, Peter Rabbitson <rabbit+dbic at rabbit.us> wrote:
>
> The test is comprehensive enough, no further questions. It would be
> great if you could convert it to a DBIC-internal test, for example based
> off of:
> https://github.com/dbsrgits/dbix-class/blob/master/t/prefetch/via_search_related.t
> (otherwise one of us got to do it, tests added to the core suite need to
> follow the internal schema)
I've had a go, trying to preserve the intent of Colin's original test
- it still fails locally with the newer DBIC; I realise there's scope
for some improvement in the test, but I didn't want to start messing
about with it too much.
Hopefully it's easier for you to make any final tweaks:
---- cut here ----
use strict;
use warnings;
use Test::More;
use lib 't/lib';
use DBICTest;
my $schema = DBICTest->init_schema();
ok (my $artist = $schema->resultset('Artist')->create({artistid=>804,
name=>'thefoo'}), "Add an artist 'thefoo'");
my $cds = [{cdid=>101,title=>'foobar_1',year=>1974},{cdid=>102,title=>'foobar_2',year=>1974}];
foreach my $cd (@{$cds}){
ok ($artist->create_related('cds', $cd), "Added a CD for artist 'thefoo'");
}
my $found_artist = $schema->resultset('Artist')->find(
{'me.artistid' => 804},
{ prefetch => 'cds' }
);
my $cd = $found_artist->cds->search({cdid => 102});
is ($cd->first->id, 102, "Expected CD with ID 102");
done_testing;
---- cut here ----
Chiz
--
Chisel
e: chisel at chizography.net
w: http://chizography.net
More information about the DBIx-Class
mailing list