X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F61findnot.t;h=89070ce6e9cbce592a56a204e97967c89f7753e4;hb=698313005dbb1ea5f0b19ce6cd7ea45ac01f16ef;hp=6d23dc9ced50449cd86535eb728968a56e0944cf;hpb=cf48da0c9ecff776e12d1f194c3be24b8079f1f4;p=dbsrgits%2FDBIx-Class.git diff --git a/t/61findnot.t b/t/61findnot.t index 6d23dc9..89070ce 100644 --- a/t/61findnot.t +++ b/t/61findnot.t @@ -47,24 +47,45 @@ 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'); +for my $key ('', 'primary') { + my $art = $artist_rs->find({ name => 'some other name' }, { $key ? (key => $key) : () }); + is($art->artistid, $cd->get_column('artist'), "Artist found through @{[ $key ? 'explicit' : 'implicit' ]} key locked in the resultset"); +} # collapsing and non-collapsing are separate codepaths, thus the separate tests + $artist_rs = $schema->resultset("Artist"); + warnings_exist { $artist_rs->find({}) -} qr/\QDBIx::Class::ResultSet::find(): Query returned more than one row. SQL that returns multiple rows is DEPRECATED for ->find and ->single/ +} qr/\QQuery returned more than one row. SQL that returns multiple rows is DEPRECATED for ->find and ->single/ => "Non-unique find generated a cursor inexhaustion warning"; + throws_ok { $artist_rs->find({}, { key => 'primary' }) } qr/Unable to satisfy requested constraint 'primary'/; +for (1, 0) { + local $ENV{DBIC_NULLABLE_KEY_NOWARN}; + warnings_like + sub { + $artist_rs->find({ artistid => undef }, { key => 'primary' }) + }, + $_ ? [ + qr/undef values supplied for requested unique constraint.+almost certainly not what you wanted/, + ] : [], + 'One warning on NULL conditions for constraint' + ; +} + + $artist_rs = $schema->resultset("Artist")->search({}, { prefetch => 'cds' }); + warnings_exist { $artist_rs->find({}) } qr/\QDBIx::Class::ResultSet::find(): Query returned more than one row/, "Non-unique find generated a cursor inexhaustion warning"; + throws_ok { $artist_rs->find({}, { key => 'primary' }) } qr/Unable to satisfy requested constraint 'primary'/;