X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F80unique.t;h=eebb66eb05bd7271ee68440f930b4d9a2d939cf3;hb=8070a15198fd37ee7ddcffbc1857a687b3d773b6;hp=ad62f0f40bf7087258fb9bf208d076e050a5fedc;hpb=365d06b716eb2b3894d83291c612b116ade1e9d7;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/80unique.t b/t/80unique.t index ad62f0f..eebb66e 100644 --- a/t/80unique.t +++ b/t/80unique.t @@ -7,7 +7,7 @@ use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 39; +plan tests => 43; # Check the defined unique constraints is_deeply( @@ -140,7 +140,7 @@ is($cd9->get_column('artist'), $cd1->get_column('artist'), 'artist is correct'); is($cd9->title, $cd1->title, 'title is correct'); is($cd9->year, 2021, 'year is correct'); -# KNOWN TO FAIL: Table with two unique constraints, and we're satisying one of them +# Table with two unique constraints, and we're satisying one of them my $track = $schema->resultset('Track')->find( { cd => 1, @@ -151,3 +151,17 @@ my $track = $schema->resultset('Track')->find( is($track->get_column('cd'), 1, 'track cd is correct'); is($track->get_column('position'), 3, 'track position is correct'); + +# Test a table with a unique constraint but no primary key +my $row = $schema->resultset('NoPrimaryKey')->update_or_create( + { + foo => 1, + bar => 2, + baz => 3, + }, + { key => 'foo_bar' } +); +ok(! $row->is_changed, 'update_or_create on table without primary key: row is clean'); +is($row->foo, 1, 'foo is correct'); +is($row->bar, 2, 'bar is correct'); +is($row->baz, 3, 'baz is correct');