implemented _collapse_result and _merge_result
[dbsrgits/DBIx-Class.git] / t / resultset / as_subselect_rs.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6
7 use lib qw(t/lib);
8 use DBICTest;
9 use DBIC::SqlMakerTest;
10
11 my $schema = DBICTest->init_schema();
12
13 my $new_rs = $schema->resultset('Artist')->search({
14    'artwork_to_artist.artist_id' => 1
15 }, {
16    join => 'artwork_to_artist'
17 });
18 lives_ok { $new_rs->count } 'regular search works';
19 lives_ok { $new_rs->search({ 'artwork_to_artist.artwork_cd_id' => 1})->count }
20    '... and chaining off that using join works';
21 lives_ok { $new_rs->search({ 'artwork_to_artist.artwork_cd_id' => 1})->as_subselect_rs->count }
22    '... and chaining off the virtual view works';
23 dies_ok  { $new_rs->as_subselect_rs->search({'artwork_to_artist.artwork_cd_id'=> 1})->count }
24    q{... but chaining off of a virtual view using join doesn't work};
25 done_testing;