10 my $schema = DBICTest->init_schema();
12 my $orig_debug = $schema->storage->debug;
17 eval "use DBD::SQLite";
19 ? ( skip_all => 'needs DBD::SQLite for testing' )
23 # A search() with prefetch seems to pollute an already joined resultset
24 # in a way that offsets future joins (adapted from a test case by Debolaz)
28 # test a real-life case - rs is obtained by an implicit m2m join
29 $cd_rs = $schema->resultset ('Producer')->first->cds;
30 $attrs = Dumper $cd_rs->{attrs};
32 $cd_rs->search ({})->all;
33 is (Dumper ($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after a simple search');
36 $cd_rs->search ({'artist.artistid' => 1}, { prefetch => 'artist' })->all;
37 is (Dumper ($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after search with prefetch');
38 }, 'first prefetching search ok');
41 $cd_rs->search ({'artist.artistid' => 1}, { prefetch => 'artist' })->all;
42 is (Dumper ($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after another search with prefetch')
43 }, 'second prefetching search ok');
46 # test a regular rs with an empty seen_join injected - it should still work!
47 $cd_rs = $schema->resultset ('CD');
48 $cd_rs->{attrs}{seen_join} = {};
49 $attrs = Dumper $cd_rs->{attrs};
51 $cd_rs->search ({})->all;
52 is (Dumper ($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after a simple search');
55 $cd_rs->search ({'artist.artistid' => 1}, { prefetch => 'artist' })->all;
56 is (Dumper ($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after search with prefetch');
57 }, 'first prefetching search ok');
60 $cd_rs->search ({'artist.artistid' => 1}, { prefetch => 'artist' })->all;
61 is (Dumper ($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after another search with prefetch')
62 }, 'second prefetching search ok');