__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' );
--- /dev/null
+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;