Fix possible regression with prefetch select resolution
[dbsrgits/DBIx-Class.git] / t / prefetch / attrs_untouched.t
1 use warnings;  
2
3 use Test::More;
4 use Test::Exception;
5 use lib qw(t/lib);
6 use DBICTest;
7 use Data::Dumper;
8
9 my $schema = DBICTest->init_schema();
10
11 plan tests => 3;
12
13 # bug in 0.07000 caused attr (join/prefetch) to be modifed by search
14 # so we check the search & attr arrays are not modified
15 my $search = { 'artist.name' => 'Caterwauler McCrae' };
16 my $attr = { prefetch => [ qw/artist liner_notes/ ],
17              order_by => 'me.cdid' };
18 my $search_str = Dumper($search);
19 my $attr_str = Dumper($attr);
20
21 my $rs = $schema->resultset("CD")->search($search, $attr);
22
23 is(Dumper($search), $search_str, 'Search hash untouched after search()');
24 is(Dumper($attr), $attr_str, 'Attribute hash untouched after search()');
25 cmp_ok($rs + 0, '==', 3, 'Correct number of records returned');