Fix possible regression with prefetch select resolution
[dbsrgits/DBIx-Class.git] / t / prefetch / attrs_untouched.t
CommitLineData
e9bd1473 1use warnings;
2
3use Test::More;
4use Test::Exception;
5use lib qw(t/lib);
6use DBICTest;
7use Data::Dumper;
8
9my $schema = DBICTest->init_schema();
10
f1952f5c 11plan tests => 3;
e9bd1473 12
e9bd1473 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
15my $search = { 'artist.name' => 'Caterwauler McCrae' };
16my $attr = { prefetch => [ qw/artist liner_notes/ ],
17 order_by => 'me.cdid' };
18my $search_str = Dumper($search);
19my $attr_str = Dumper($attr);
20
21my $rs = $schema->resultset("CD")->search($search, $attr);
22
23is(Dumper($search), $search_str, 'Search hash untouched after search()');
24is(Dumper($attr), $attr_str, 'Attribute hash untouched after search()');
25cmp_ok($rs + 0, '==', 3, 'Correct number of records returned');