From: Alexander Hartmaier Date: Thu, 16 Dec 2010 14:52:53 +0000 (+0100) Subject: added tests for RT#63709 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fwip%2Fwhere_relattr_tests;p=dbsrgits%2FDBIx-Class.git added tests for RT#63709 --- diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index 8087292..c993d72 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -134,6 +134,10 @@ __PACKAGE__->has_many( __PACKAGE__->has_many( cds_very_very_very_long_relationship_name => 'DBICTest::Schema::CD' ); +__PACKAGE__->has_many( + year2001_cds => 'DBICTest::Schema::CD', undef, + { where => { year => 2001} }, +); __PACKAGE__->has_many( twokeys => 'DBICTest::Schema::TwoKeys' ); __PACKAGE__->has_many( onekeys => 'DBICTest::Schema::OneKey' ); diff --git a/t/prefetch/relationship_where_attr.t b/t/prefetch/relationship_where_attr.t new file mode 100644 index 0000000..c0e2014 --- /dev/null +++ b/t/prefetch/relationship_where_attr.t @@ -0,0 +1,19 @@ +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; +my $schema = DBICTest->init_schema(); + +{ + my $artist_with_year2001_cds = $schema->resultset('Artist')->find(1); + is $artist_with_year2001_cds->year2001_cds->count, 1, 'artist has one cd from 2001 without prefetching'; +} + +{ + my $artist_with_year2001_cds = $schema->resultset('Artist')->find(1, { prefetch => 'year2001_cds' }); + is $artist_with_year2001_cds->year2001_cds->count, 1, 'artist has one cd from 2001 with prefetching'; +} + +done_testing;