6 use lib 't/cdbi/testlib';
9 Film->create({ Title => $_, Rating => "PG" }) for ("Superman", "Super Fuzz");
10 Film->create({ Title => "Batman", Rating => "PG13" });
12 my $superman = Film->search_where( Title => "Superman" );
13 is $superman->next->Title, "Superman", "search_where() as iterator";
14 is $superman->next, undef;
17 my @supers = Film->search_where({ title => { 'like' => 'Super%' } });
18 is_deeply [sort map $_->Title, @supers],
19 [sort ("Super Fuzz", "Superman")], 'like';
23 my @all = Film->search_where({}, { order_by => "Title ASC" });
24 is_deeply ["Batman", "Super Fuzz", "Superman"],
25 [map $_->Title, @all],
28 @all = Film->search_where({}, { order_by => "Title DESC" });
29 is_deeply ["Superman", "Super Fuzz", "Batman"],
30 [map $_->Title, @all],
33 @all = Film->search_where({ Rating => "PG" }, { limit => 1, order_by => "Title ASC" });
34 is_deeply ["Super Fuzz"],
35 [map $_->Title, @all],
38 @all = Film->search_where({}, { limit => 2, order_by => "Title ASC" });
39 is_deeply ["Batman", "Super Fuzz"],
40 [map $_->Title, @all],
43 @all = Film->search_where({}, { offset => 1, order_by => "Title ASC" });
44 is_deeply ["Super Fuzz", "Superman"],
45 [map $_->Title, @all],
48 @all = Film->search_where({}, { limit => 1, offset => 1, order_by => "Title ASC" });
49 is_deeply ["Super Fuzz"],
50 [map $_->Title, @all],
53 @all = Film->search_where({}, { limit => 2, offset => 1,
54 limit_dialect => "Top", order_by => "Title ASC"
56 is_deeply ["Super Fuzz", "Superman"],
57 [map $_->Title, @all],
58 "limit_dialect ignored";