From: Peter Rabbitson Date: Sat, 16 Oct 2010 23:51:33 +0000 (+0200) Subject: Test for already fixed RT#59219 X-Git-Tag: v0.08124~37^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e29e2b27d08d645f8a50d7ffafef28c67688207e;p=dbsrgits%2FDBIx-Class.git Test for already fixed RT#59219 --- diff --git a/t/80unique.t b/t/80unique.t index 2264f61..7f78ef5 100644 --- a/t/80unique.t +++ b/t/80unique.t @@ -3,6 +3,7 @@ use warnings; use Test::More; use Test::Exception; +use Test::Warn; use lib qw(t/lib); use DBICTest; use DBIC::SqlMakerTest; @@ -228,6 +229,8 @@ is($row->baz, 3, 'baz is correct'); my $artist = $schema->resultset('Artist')->next; my ($sql, @bind); + my $old_debugobj = $schema->storage->debugobj; + my $old_debug = $schema->storage->debug; $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)), $schema->storage->debug(1); @@ -240,8 +243,8 @@ is($row->baz, 3, 'baz is correct'); [qw/'1'/], ); - $schema->storage->debug(0); - $schema->storage->debugobj(undef); + $schema->storage->debug($old_debug); + $schema->storage->debugobj($old_debugobj); } { @@ -266,7 +269,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; diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index 62bd946..b089287 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -32,6 +32,7 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key('artistid'); __PACKAGE__->add_unique_constraint(['name']); __PACKAGE__->add_unique_constraint(artist => ['artistid']); # do not remove, part of a test +__PACKAGE__->add_unique_constraint(u_nullable => [qw/charfield rank/]); __PACKAGE__->mk_classdata('field_name_for', { diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index e53bb23..9178263 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -1,6 +1,6 @@ -- -- Created by SQL::Translator::Producer::SQLite --- Created on Sat Oct 16 16:17:01 2010 +-- Created on Sun Oct 17 01:51:06 2010 -- -- @@ -17,6 +17,8 @@ CREATE INDEX artist_name_hookidx ON artist (name); CREATE UNIQUE INDEX artist_name ON artist (name); +CREATE UNIQUE INDEX u_nullable ON artist (charfield, rank); + -- -- Table: bindtype_test --