X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F60core.t;h=d848a9154747763c675e6be587813bac0294b3ff;hb=2c2bc4e58c2146670960fc1a0a2ae802cb650506;hp=ffb7d1340802417b9ba2f0dba9cb9b0503b2adde;hpb=a2f228547345e788da5a047024c41f83513e92b8;p=dbsrgits%2FDBIx-Class.git diff --git a/t/60core.t b/t/60core.t index ffb7d13..d848a91 100644 --- a/t/60core.t +++ b/t/60core.t @@ -5,8 +5,7 @@ use Test::More; use Test::Exception; use Test::Warn; use lib qw(t/lib); -use DBICTest; -use DBIC::SqlMakerTest; +use DBICTest ':DiffSQL'; my $schema = DBICTest->init_schema(); @@ -131,6 +130,13 @@ throws_ok { is($schema->resultset("Artist")->count, 4, 'count ok'); +# test find on an unresolvable condition +is( + $schema->resultset('Artist')->find({ artistid => [ -and => 1, 2 ]}), + undef +); + + # test find_or_new { my $existing_obj = $schema->resultset('Artist')->find_or_new({ @@ -173,7 +179,7 @@ is_deeply( \@cd, [qw/cdid artist title year genreid single_track/], 'column orde $cd = $schema->resultset("CD")->search({ title => 'Spoonful of bees' }, { columns => ['title'] })->next; is($cd->title, 'Spoonful of bees', 'subset of columns returned correctly'); -$cd = $schema->resultset("CD")->search(undef, { include_columns => [ { name => 'artist.name' } ], join => [ 'artist' ] })->find(1); +$cd = $schema->resultset("CD")->search(undef, { '+columns' => [ { name => 'artist.name' } ], join => [ 'artist' ] })->find(1); is($cd->title, 'Spoonful of bees', 'Correct CD returned with include'); is($cd->get_column('name'), 'Caterwauler McCrae', 'Additional column returned'); @@ -243,7 +249,7 @@ is($schema->class("Artist")->field_name_for->{name}, 'artist name', 'mk_classdat my $search = [ { 'tags.tag' => 'Cheesy' }, { 'tags.tag' => 'Blue' } ]; -my( $or_rs ) = $schema->resultset("CD")->search_rs($search, { join => 'tags', +my $or_rs = $schema->resultset("CD")->search_rs($search, { join => 'tags', order_by => 'cdid' }); is($or_rs->all, 5, 'Joined search with OR returned correct number of rows'); is($or_rs->count, 5, 'Search count with OR ok'); @@ -292,7 +298,7 @@ is ($collapsed_or_rs->count, 4, 'Collapsed search count with OR ok'); my $tag_rs = $schema->resultset('Tag')->search( [ { 'me.tag' => 'Cheesy' }, { 'me.tag' => 'Blue' } ]); -my $rel_rs = $tag_rs->search_related('cd'); +my $rel_rs = $tag_rs->search_related('cd', {}, { order_by => 'cd.cdid'} ); is($rel_rs->count, 5, 'Related search ok'); @@ -309,7 +315,9 @@ for (keys %{$schema->storage->dbh->{CachedKids}}) { } my $tag = $schema->resultset('Tag')->search( - [ { 'me.tag' => 'Blue' } ], { cols=>[qw/tagid/] } )->next; + [ { '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'); @@ -568,13 +576,15 @@ lives_ok (sub { my $newlink = $newbook->link}, "stringify to false value doesn't { my $new_artist = $schema->resultset('Artist')->new({}); isa_ok( $new_artist, 'DBIx::Class::Row', '$rs->new gives a row object' ); + lives_ok { $new_artist->insert() } 'inserting without specifying any columns works'; + $new_artist->discard_changes; + $new_artist->delete; } - # make sure we got rid of the compat shims SKIP: { my $remove_version = 0.083; - skip "Remove in $remove_version", 3 if $DBIx::Class::VERSION < $remove_version; + skip "Remove in $remove_version", 3 if DBIx::Class->VERSION < $remove_version; for (qw/compare_relationship_keys pk_depends_on resolve_condition/) { ok (! DBIx::Class::ResultSource->can ($_), "$_ no longer provided by DBIx::Class::ResultSource, removed before $remove_version"); @@ -617,7 +627,7 @@ SKIP: { #------------------------------ # SKIP: { - skip "Something needs to be done before 0.09", 2 if $DBIx::Class::VERSION < 0.09; + skip "Something needs to be done before 0.09", 2 if DBIx::Class->VERSION < 0.09; my $row = $schema->resultset ('Artist')->next;