X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F61findnot.t;h=84794940e4a798e1aae080035079e9ce74868047;hb=d2f4cc4a86585dbaf0bda33cf9c1d4403b6397a4;hp=ee7b582ea6274ed0383cc9d6201b6a7256776f17;hpb=57dc206ebd7065abc265ef81c729f16b97e6ab5a;p=dbsrgits%2FDBIx-Class.git diff --git a/t/61findnot.t b/t/61findnot.t index ee7b582..8479494 100644 --- a/t/61findnot.t +++ b/t/61findnot.t @@ -2,12 +2,13 @@ use strict; use warnings; use Test::More; +use Test::Warn; use lib qw(t/lib); use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 17; +plan tests => 20; my $art = $schema->resultset("Artist")->find(4); ok(!defined($art), 'Find on primary id: artist not found'); @@ -44,3 +45,19 @@ $cd = $schema->resultset("CD")->search({title => 'Call of the West'}); @cd = $cd->single; cmp_ok(@cd, '==', 1, 'Return something even in array context'); ok(@cd && !defined($cd[0]), 'Array contains an undef as only element'); + +$cd = $schema->resultset("CD")->first; +my $artist_rs = $schema->resultset("Artist")->search({ artistid => $cd->artist->artistid }); +$art = $artist_rs->find({ name => 'some other name' }, { key => 'primary' }); +ok($art, 'Artist found by key in the resultset'); + +$artist_rs = $schema->resultset("Artist"); +warning_is { + $artist_rs->find({}, { key => 'primary' }) +} "DBIx::Class::ResultSet::find(): Query returned more than one row. SQL that returns multiple rows is DEPRECATED for ->find and ->single" + => "Non-unique find generated a cursor inexhaustion warning"; + +$artist_rs = $schema->resultset("Artist")->search({}, { prefetch => 'cds' }); +warning_is { + $artist_rs->find({}, { key => 'primary' }) +} "DBIx::Class::ResultSet::find(): Query returned more than one row", "Non-unique find generated a cursor inexhaustion warning";