9 eval "use DBIx::Class::CDBICompat;";
11 plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@");
14 eval "use DBD::SQLite";
15 plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 10);
24 Film->create({ Title => $_, Rating => "PG" }) for ("Superman", "Super Fuzz");
25 Film->create({ Title => "Batman", Rating => "PG13" });
27 my $superman = Film->search_where( Title => "Superman" );
28 is $superman->next->Title, "Superman", "search_where() as iterator";
29 is $superman->next, undef;
32 my @supers = Film->search_where({ title => { 'like' => 'Super%' } });
33 is_deeply [sort map $_->Title, @supers],
34 [sort ("Super Fuzz", "Superman")], 'like';
38 my @all = Film->search_where({}, { order_by => "Title ASC" });
39 is_deeply ["Batman", "Super Fuzz", "Superman"],
40 [map $_->Title, @all],
43 @all = Film->search_where({}, { order_by => "Title DESC" });
44 is_deeply ["Superman", "Super Fuzz", "Batman"],
45 [map $_->Title, @all],
48 @all = Film->search_where({ Rating => "PG" }, { limit => 1, order_by => "Title ASC" });
49 is_deeply ["Super Fuzz"],
50 [map $_->Title, @all],
53 @all = Film->search_where({}, { limit => 2, order_by => "Title ASC" });
54 is_deeply ["Batman", "Super Fuzz"],
55 [map $_->Title, @all],
58 @all = Film->search_where({}, { offset => 1, order_by => "Title ASC" });
59 is_deeply ["Super Fuzz", "Superman"],
60 [map $_->Title, @all],
63 @all = Film->search_where({}, { limit => 1, offset => 1, order_by => "Title ASC" });
64 is_deeply ["Super Fuzz"],
65 [map $_->Title, @all],
68 @all = Film->search_where({}, { limit => 2, offset => 1,
69 limit_dialect => "Top", order_by => "Title ASC"
71 is_deeply ["Super Fuzz", "Superman"],
72 [map $_->Title, @all],
73 "limit_dialect ignored";