1 use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
8 use lib 't/cdbi/testlib';
11 Film->create({ Title => $_, Rating => "PG" }) for ("Superman", "Super Fuzz");
12 Film->create({ Title => "Batman", Rating => "PG13" });
14 my $superman = Film->search_where( Title => "Superman" );
15 is $superman->next->Title, "Superman", "search_where() as iterator";
16 is $superman->next, undef;
19 my @supers = Film->search_where({ title => { 'like' => 'Super%' } });
20 is_deeply [sort map $_->Title, @supers],
21 [sort ("Super Fuzz", "Superman")], 'like';
25 my @all = Film->search_where({}, { order_by => "Title ASC" });
26 is_deeply ["Batman", "Super Fuzz", "Superman"],
27 [map $_->Title, @all],
30 @all = Film->search_where({}, { order_by => "Title DESC" });
31 is_deeply ["Superman", "Super Fuzz", "Batman"],
32 [map $_->Title, @all],
35 @all = Film->search_where({ Rating => "PG" }, { limit => 1, order_by => "Title ASC" });
36 is_deeply ["Super Fuzz"],
37 [map $_->Title, @all],
40 @all = Film->search_where({}, { limit => 2, order_by => "Title ASC" });
41 is_deeply ["Batman", "Super Fuzz"],
42 [map $_->Title, @all],
45 @all = Film->search_where({}, { offset => 1, order_by => "Title ASC" });
46 is_deeply ["Super Fuzz", "Superman"],
47 [map $_->Title, @all],
50 @all = Film->search_where({}, { limit => 1, offset => 1, order_by => "Title ASC" });
51 is_deeply ["Super Fuzz"],
52 [map $_->Title, @all],
55 @all = Film->search_where({}, { limit => 2, offset => 1,
56 limit_dialect => "Top", order_by => "Title ASC"
58 is_deeply ["Super Fuzz", "Superman"],
59 [map $_->Title, @all],
60 "limit_dialect ignored";