use strict;
+use warnings;
use Test::More;
-BEGIN {
- eval "use DBIx::Class::CDBICompat;";
- if ($@) {
- plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required');
- }
- plan tests => 20;
-}
-
use lib 't/cdbi/testlib';
use Film;
use Actor;
my @cols = Film->columns('Essential');
is_deeply \@cols, ['title'], "1 Column in essential";
is +Film->transform_sql('__ESSENTIAL__'), 'title', '__ESSENTIAL__ expansion';
-
+
# This provides a more interesting test
Film->columns(Essential => qw(title rating));
is +Film->transform_sql('__ESSENTIAL__'), 'title, rating',
SELECT __ESSENTIAL__
FROM __TABLE__
WHERE __TABLE__.rating = 'PG'
- ORDER BY title DESC
+ ORDER BY title DESC
}
);
SELECT __ESSENTIAL__
FROM __TABLE__
WHERE rating = ?
- ORDER BY title DESC
+ ORDER BY title DESC
}
);
WHERE __IDENTIFIER__
}
);
-
+
my $film = Film->retrieve_all->first;
my @found = Film->search_by_id($film->id);
is @found, 1;
Film->set_sql(
namerate => qq{
SELECT __ESSENTIAL(f)__
- FROM __TABLE(=f)__, __TABLE(Actor=a)__
- WHERE __JOIN(a f)__
+ FROM __TABLE(=f)__, __TABLE(Actor=a)__
+ WHERE __JOIN(a f)__
AND a.name LIKE ?
AND f.rating = ?
- ORDER BY title
+ ORDER BY title
}
);
Film->set_sql(
ratename => qq{
SELECT __ESSENTIAL(f)__
- FROM __TABLE(=f)__, __TABLE(Actor=a)__
- WHERE __JOIN(f a)__
+ FROM __TABLE(=f)__, __TABLE(Actor=a)__
+ WHERE __JOIN(f a)__
AND f.rating = ?
AND a.name LIKE ?
- ORDER BY title
+ ORDER BY title
}
);
is $apg[1]->title, "B", "and B";
}
+done_testing;