7 eval "use DBIx::Class::CDBICompat;";
9 plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@");
12 eval "use DBD::SQLite";
13 plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 10);
17 use lib 't/cdbi/testlib';
22 Film->create({ Title => $_, Rating => "PG" }) for ("Superman", "Super Fuzz");
23 Film->create({ Title => "Batman", Rating => "PG13" });
25 my $superman = Film->search_where( Title => "Superman" );
26 is $superman->next->Title, "Superman", "search_where() as iterator";
27 is $superman->next, undef;
30 my @supers = Film->search_where({ title => { 'like' => 'Super%' } });
31 is_deeply [sort map $_->Title, @supers],
32 [sort ("Super Fuzz", "Superman")], 'like';
36 my @all = Film->search_where({}, { order_by => "Title ASC" });
37 is_deeply ["Batman", "Super Fuzz", "Superman"],
38 [map $_->Title, @all],
41 @all = Film->search_where({}, { order_by => "Title DESC" });
42 is_deeply ["Superman", "Super Fuzz", "Batman"],
43 [map $_->Title, @all],
46 @all = Film->search_where({ Rating => "PG" }, { limit => 1, order_by => "Title ASC" });
47 is_deeply ["Super Fuzz"],
48 [map $_->Title, @all],
51 @all = Film->search_where({}, { limit => 2, order_by => "Title ASC" });
52 is_deeply ["Batman", "Super Fuzz"],
53 [map $_->Title, @all],
56 @all = Film->search_where({}, { offset => 1, order_by => "Title ASC" });
57 is_deeply ["Super Fuzz", "Superman"],
58 [map $_->Title, @all],
61 @all = Film->search_where({}, { limit => 1, offset => 1, order_by => "Title ASC" });
62 is_deeply ["Super Fuzz"],
63 [map $_->Title, @all],
66 @all = Film->search_where({}, { limit => 2, offset => 1,
67 limit_dialect => "Top", order_by => "Title ASC"
69 is_deeply ["Super Fuzz", "Superman"],
70 [map $_->Title, @all],
71 "limit_dialect ignored";