use
5.010_001;
BEGIN {
use_ok(
'DBIx::Squirrel'
,
database_entities
=> [
qw/db artist artists/
]) ||
print
"Bail out!\n"
;
use_ok(
'T::Squirrel'
,
qw/:var diagdump/
) ||
print
"Bail out!\n"
;
}
diag(
"Testing DBIx::Squirrel $DBIx::Squirrel::VERSION, Perl $], $^X"
);
sub
filter {(
$_
->ArtistId < 128 or
$_
->ArtistId > 131) ? () :
$_
}
sub
artist_name {(
$_
->ArtistId == 128) ? (
$_
->Name,
'Envy of None'
,
'Alex Lifeson'
) :
$_
->[1]}
db(DBIx::Squirrel->
connect
(
@TEST_DB_CONNECT_ARGS
));
artist(db->results(
'SELECT * FROM artists WHERE ArtistId=? LIMIT 1'
));
my
$artist
= artist->_private_state;
artists(db->results(
'SELECT * FROM artists ORDER BY ArtistId'
=> \
&filter
=> \
&artist_name
));
my
$artists
= artists->_private_state;
my
$results
= artists->all;
my
$expected
= [
'Rush'
,
'Envy of None'
,
'Alex Lifeson'
,
'Simply Red'
,
'Skank'
,
'Smashing Pumpkins'
];
is_deeply(
$results
,
$expected
,
'iteration, filtering, injection ok'
);
is(
$artists
->{cache_size_fixed}, !!0,
'artists->{cache_size_fixed}'
);
is(
$artists
->{cache_size},
&DBIx::Squirrel::Iterator::CACHE_SIZE_LIMIT
,
'artists->{cache_size}'
);
artists->cache_size(8)->execute;
$results
= artists->all;
is_deeply(
$results
,
$expected
,
'iteration, filtering, injection ok'
);
is(
$artists
->{cache_size_fixed}, !!1,
'artists->{cache_size_fixed}'
);
is(
$artists
->{cache_size}, 8,
'artists->{cache_size}'
);
done_testing();