DBIx-Class
view release on metacpan or search on metacpan
is($or_rs->next->cdid, $rel_rs->next->cdid, 'Related object ok');
$or_rs->reset;
$rel_rs->reset;
# at this point there should be no active statements
# (finish() was called everywhere, either explicitly via
# reset() or on DESTROY)
for (keys %{$schema->storage->dbh->{CachedKids}}) {
fail("Unreachable cached statement still active: $_")
if $schema->storage->dbh->{CachedKids}{$_}->FETCH('Active');
}
my $tag = $schema->resultset('Tag')->search(
[ { 'me.tag' => 'Blue' } ],
{ columns => 'tagid' }
)->next;
ok($tag->has_column_loaded('tagid'), 'Has tagid loaded');
ok(!$tag->has_column_loaded('tag'), 'Has not tag loaded');
ok($schema->storage(), 'Storage available');
{
my $rs = $schema->resultset("Artist")->search({
-and => [
artistid => { '>=', 1 },
artistid => { '<', 3 }
]
});
$rs->update({ rank => 6134 });
my $art;
$art = $schema->resultset("Artist")->find(1);
is($art->rank, 6134, 'updated first artist rank');
$art = $schema->resultset("Artist")->find(2);
is($art->rank, 6134, 'updated second artist rank');
}
# test source_name
{
# source_name should be set for normal modules
is($schema->source('CD')->source_name, 'CD', 'source_name is set to moniker');
# test the result source that sets source_name explictly
ok($schema->source('SourceNameArtists'), 'SourceNameArtists result source exists');
my @artsn = $schema->resultset('SourceNameArtists')->search({}, { order_by => 'name DESC' });
is(@artsn, 4, "Four artists returned");
# make sure subclasses that don't set source_name are ok
ok($schema->source('ArtistSubclass'), 'ArtistSubclass exists');
}
my $newbook = $schema->resultset( 'Bookmark' )->find(1);
lives_ok (sub { my $newlink = $newbook->link}, "stringify to false value doesn't cause error");
# test cascade_delete through many_to_many relations
{
my $art_del = $schema->resultset("Artist")->find({ artistid => 1 });
lives_ok (sub { $art_del->delete }, 'Cascading delete on Ordered has_many works' ); # real test in ordered.t
is( $schema->resultset("CD")->search({artist => 1}), 0, 'Cascading through has_many top level.');
is( $schema->resultset("CD_to_Producer")->search({cd => 1}), 0, 'Cascading through has_many children.');
}
# test column_info
{
$schema->source("Artist")->{_columns}{'artistid'} = {};
$schema->source("Artist")->column_info_from_storage(1);
my $typeinfo = $schema->source("Artist")->column_info('artistid');
is($typeinfo->{data_type}, 'INTEGER', 'column_info ok');
$schema->source("Artist")->column_info('artistid');
ok($schema->source("Artist")->{_columns_info_loaded} == 1, 'Columns info loaded flag set');
}
# test columns_info
{
$schema->source("Artist")->{_columns}{'artistid'} = {};
$schema->source("Artist")->column_info_from_storage(1);
$schema->source("Artist")->{_columns_info_loaded} = 0;
cmp_deeply (
$schema->source('Artist')->columns_info,
{
artistid => {
data_type => "INTEGER",
default_value => undef,
is_nullable => 0,
size => undef
},
charfield => {
data_type => "char",
default_value => undef,
is_nullable => 1,
size => 10
},
name => {
data_type => "varchar",
default_value => undef,
is_nullable => 1,
is_numeric => 0,
size => 100
},
rank => {
data_type => re(qr/^integer$/i),
default_value => 13,
is_nullable => 0,
size => undef
},
},
'columns_info works',
);
ok($schema->source("Artist")->{_columns_info_loaded} == 1, 'Columns info loaded flag set');
cmp_deeply (
$schema->source('Artist')->columns_info([qw/artistid rank/]),
( run in 0.672 second using v1.01-cache-2.11-cpan-d8267643d1d )