X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F80unique.t;h=726a2b22cbd39668d24df24149cf48c709166164;hb=4c90556806f286093d0806e858abdba329e6dfd3;hp=2264f616bccbca7580739018657b19aa3feb7825;hpb=b7743dabe3354b4a43954ec44a226dc1c44722ac;p=dbsrgits%2FDBIx-Class.git diff --git a/t/80unique.t b/t/80unique.t index 2264f61..726a2b2 100644 --- a/t/80unique.t +++ b/t/80unique.t @@ -1,12 +1,13 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; use warnings; use Test::More; use Test::Exception; -use lib qw(t/lib); +use Test::Warn; + use DBICTest; -use DBIC::SqlMakerTest; -use DBIC::DebugObj; my $schema = DBICTest->init_schema(); @@ -225,23 +226,14 @@ is($row->baz, 3, 'baz is correct'); # make sure the ident condition is assembled sanely { - my $artist = $schema->resultset('Artist')->next; - - my ($sql, @bind); - $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)), - $schema->storage->debug(1); - - $artist->discard_changes; - - is_same_sql_bind ( - $sql, - \@bind, - 'SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me WHERE me.artistid = ?', - [qw/'1'/], - ); - - $schema->storage->debug(0); - $schema->storage->debugobj(undef); + my $artist = $schema->resultset('Artist')->find(1); + + $schema->is_executed_sql_bind( sub { $artist->discard_changes }, [ + [ + 'SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me WHERE me.artistid = ?', + [ { dbic_colname => "me.artistid", sqlt_datatype => "integer" } => 1 ], + ] + ], 'Expected query on discard_changes'); } { @@ -266,7 +258,22 @@ MOD } qr/\Qadd_unique_constraint() does not accept multiple constraints, use add_unique_constraints() instead\E/, 'add_unique_constraint throws when more than one constraint specified'; } +# make sure NULL is not considered condition-deterministic +my $art_rs = $schema->resultset('Artist')->search({}, { order_by => 'artistid' }); +$art_rs->create ({ artistid => $_ + 640, name => "Outranked $_" }) for (1..2); +warnings_are { + is( + $art_rs->find ({ artistid => 642, rank => 13, charfield => undef })->name, + 'Outranked 2', + 'Correct artist retrieved with find' + ); + is ( + $art_rs->search({ charfield => undef })->find ({ artistid => 642, rank => 13 })->name, + 'Outranked 2', + 'Correct artist retrieved with find' + ); +} [], 'no warnings'; done_testing;