9 use DBIC::SqlMakerTest;
10 use Data::Query::ExprDeclare;
11 use Data::Query::ExprHelpers;
12 use DBIx::Class::PerlRenderer::MangleStrings;
14 my $schema = DBICTest->init_schema();
16 my $cds = $schema->resultset('CD');
18 my $restricted = $cds->search({}, { cache => 1, grep_cache => 1 })
19 ->search({ 'me.artist' => 1 });
21 is($restricted->count, 3, 'Count on restricted ok');
23 $restricted = $cds->search(
25 { prefetch => 'artist', cache => 1, grep_cache => 1 }
27 ->search({ 'artist.name' => 'Caterwauler McCrae' });
29 is($restricted->count, 3, 'Count on restricted ok via join');
31 my $title_cond = \expr { $_->me->title eq 'Foo' }->{expr};
33 my $pred_normal = $cds->_construct_perl_predicate($title_cond);
36 $schema->storage->perl_renderer,
37 'DBIx::Class::PerlRenderer::MangleStrings',
40 my $pred_mangle = $cds->_construct_perl_predicate($title_cond);
42 foreach my $t ([ 'Foo', 1, 1 ], [ 'foo ', 0, 1 ]) {
43 my $obj = $cds->new_result({ title => $t->[0] });
44 foreach my $p ([ Normal => $pred_normal, 1 ], [ Mangle => $pred_mangle, 2 ]) {
45 is(($p->[1]->($obj) ? 1 : 0), $t->[$p->[2]], join(': ', $p->[0], $t->[0]));