Beta Shell
v2.0 ยท web2.us.cloudlogin.co
[FM]
[CMD]
[PHP]
[DB]
[INFO]
[SEC]
File Manager
~
/
usr
/
share
/
doc
/
perl-DBIx-Class
/
t
/
cdbi
/
abstract
Upload
3 items
Name
Size
Perms
Modified
Actions
[ .. / .. ]
search_where.t
1.83 KB
-rw-r--r--
2020-03-29 18:33:33
Edit
Del
Editing: search_where.t
(1.83 KB)
Path: /usr/share/doc/perl-DBIx-Class/t/cdbi/abstract/search_where.t
Back
use Test::More; use strict; use warnings; INIT { use lib 't/cdbi/testlib'; use Film; } Film->create({ Title => $_, Rating => "PG" }) for ("Superman", "Super Fuzz"); Film->create({ Title => "Batman", Rating => "PG13" }); my $superman = Film->search_where( Title => "Superman" ); is $superman->next->Title, "Superman", "search_where() as iterator"; is $superman->next, undef; { my @supers = Film->search_where({ title => { 'like' => 'Super%' } }); is_deeply [sort map $_->Title, @supers], [sort ("Super Fuzz", "Superman")], 'like'; } my @all = Film->search_where({}, { order_by => "Title ASC" }); is_deeply ["Batman", "Super Fuzz", "Superman"], [map $_->Title, @all], "order_by ASC"; @all = Film->search_where({}, { order_by => "Title DESC" }); is_deeply ["Superman", "Super Fuzz", "Batman"], [map $_->Title, @all], "order_by DESC"; @all = Film->search_where({ Rating => "PG" }, { limit => 1, order_by => "Title ASC" }); is_deeply ["Super Fuzz"], [map $_->Title, @all], "where, limit"; @all = Film->search_where({}, { limit => 2, order_by => "Title ASC" }); is_deeply ["Batman", "Super Fuzz"], [map $_->Title, @all], "limit"; @all = Film->search_where({}, { offset => 1, order_by => "Title ASC" }); is_deeply ["Super Fuzz", "Superman"], [map $_->Title, @all], "offset"; @all = Film->search_where({}, { limit => 1, offset => 1, order_by => "Title ASC" }); is_deeply ["Super Fuzz"], [map $_->Title, @all], "limit + offset"; @all = Film->search_where({}, { limit => 2, offset => 1, limit_dialect => "Top", order_by => "Title ASC" }); is_deeply ["Super Fuzz", "Superman"], [map $_->Title, @all], "limit_dialect ignored"; done_testing;