use Test::More;
use Test::Exception;
+use Test::Warn;
use lib qw(t/lib);
use DBICTest;
use DBIC::SqlMakerTest;
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);
[qw/'1'/],
);
- $schema->storage->debug(0);
- $schema->storage->debugobj(undef);
+ $schema->storage->debug($old_debug);
+ $schema->storage->debugobj($old_debugobj);
}
{
} 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;
__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', {
--
-- Created by SQL::Translator::Producer::SQLite
--- Created on Sat Oct 16 16:17:01 2010
+-- Created on Sun Oct 17 01:51:06 2010
--
--
CREATE UNIQUE INDEX artist_name ON artist (name);
+CREATE UNIQUE INDEX u_nullable ON artist (charfield, rank);
+
--
-- Table: bindtype_test
--