7 use lib 't/cdbi/testlib';
12 Film->create({ Title => $_, Rating => "PG" }) for ("Superman", "Super Fuzz");
13 Film->create({ Title => "Batman", Rating => "PG13" });
15 my $superman = Film->search_where( Title => "Superman" );
16 is $superman->next->Title, "Superman", "search_where() as iterator";
17 is $superman->next, undef;
20 my @supers = Film->search_where({ title => { 'like' => 'Super%' } });
21 is_deeply [sort map $_->Title, @supers],
22 [sort ("Super Fuzz", "Superman")], 'like';
26 my @all = Film->search_where({}, { order_by => "Title ASC" });
27 is_deeply ["Batman", "Super Fuzz", "Superman"],
28 [map $_->Title, @all],
31 @all = Film->search_where({}, { order_by => "Title DESC" });
32 is_deeply ["Superman", "Super Fuzz", "Batman"],
33 [map $_->Title, @all],
36 @all = Film->search_where({ Rating => "PG" }, { limit => 1, order_by => "Title ASC" });
37 is_deeply ["Super Fuzz"],
38 [map $_->Title, @all],
41 @all = Film->search_where({}, { limit => 2, order_by => "Title ASC" });
42 is_deeply ["Batman", "Super Fuzz"],
43 [map $_->Title, @all],
46 @all = Film->search_where({}, { offset => 1, order_by => "Title ASC" });
47 is_deeply ["Super Fuzz", "Superman"],
48 [map $_->Title, @all],
51 @all = Film->search_where({}, { limit => 1, offset => 1, order_by => "Title ASC" });
52 is_deeply ["Super Fuzz"],
53 [map $_->Title, @all],
56 @all = Film->search_where({}, { limit => 2, offset => 1,
57 limit_dialect => "Top", order_by => "Title ASC"
59 is_deeply ["Super Fuzz", "Superman"],
60 [map $_->Title, @all],
61 "limit_dialect ignored";