7 eval "use DBIx::Class::CDBICompat;";
9 plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@");
15 use lib 't/cdbi/testlib';
20 Film->create({ Title => $_, Rating => "PG" }) for ("Superman", "Super Fuzz");
21 Film->create({ Title => "Batman", Rating => "PG13" });
23 my $superman = Film->search_where( Title => "Superman" );
24 is $superman->next->Title, "Superman", "search_where() as iterator";
25 is $superman->next, undef;
28 my @supers = Film->search_where({ title => { 'like' => 'Super%' } });
29 is_deeply [sort map $_->Title, @supers],
30 [sort ("Super Fuzz", "Superman")], 'like';
34 my @all = Film->search_where({}, { order_by => "Title ASC" });
35 is_deeply ["Batman", "Super Fuzz", "Superman"],
36 [map $_->Title, @all],
39 @all = Film->search_where({}, { order_by => "Title DESC" });
40 is_deeply ["Superman", "Super Fuzz", "Batman"],
41 [map $_->Title, @all],
44 @all = Film->search_where({ Rating => "PG" }, { limit => 1, order_by => "Title ASC" });
45 is_deeply ["Super Fuzz"],
46 [map $_->Title, @all],
49 @all = Film->search_where({}, { limit => 2, order_by => "Title ASC" });
50 is_deeply ["Batman", "Super Fuzz"],
51 [map $_->Title, @all],
54 @all = Film->search_where({}, { offset => 1, order_by => "Title ASC" });
55 is_deeply ["Super Fuzz", "Superman"],
56 [map $_->Title, @all],
59 @all = Film->search_where({}, { limit => 1, offset => 1, order_by => "Title ASC" });
60 is_deeply ["Super Fuzz"],
61 [map $_->Title, @all],
64 @all = Film->search_where({}, { limit => 2, offset => 1,
65 limit_dialect => "Top", order_by => "Title ASC"
67 is_deeply ["Super Fuzz", "Superman"],
68 [map $_->Title, @all],
69 "limit_dialect ignored";