From: David Kamholz Date: Tue, 31 Jan 2006 22:47:10 +0000 (+0000) Subject: change _create_ID to be saner for new version X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9bbd8963f80a0ab929350653eb91fa1ae502c47b;p=dbsrgits%2FDBIx-Class-Historic.git change _create_ID to be saner for new version --- diff --git a/lib/DBIx/Class/PK.pm b/lib/DBIx/Class/PK.pm index c86aed3..4c8f106 100644 --- a/lib/DBIx/Class/PK.pm +++ b/lib/DBIx/Class/PK.pm @@ -81,10 +81,9 @@ sub ID { } sub _create_ID { - my ($class,%vals) = @_; + my ($self,%vals) = @_; return undef unless 0 == grep { !defined } values %vals; - $class = ref $class || $class; - return join '|', $class, map { $_ . '=' . $vals{$_} } sort keys %vals; + return join '|', ref $self || $self, $self->result_source->name, map { $_ . '=' . $vals{$_} } sort keys %vals; } sub ident_condition { diff --git a/t/run/01core.tl b/t/run/01core.tl index 7e451ae..41a3941 100644 --- a/t/run/01core.tl +++ b/t/run/01core.tl @@ -71,7 +71,7 @@ $new_again = $schema->resultset("Artist")->find(4); is($new_again->name, 'Man With A Spoon', 'Retrieved correctly'); -is($new_again->ID, 'DBICTest::Artist|artistid=4', 'unique object id generated correctly'); +is($new_again->ID, 'DBICTest::Artist|artist|artistid=4', 'unique object id generated correctly'); is($schema->resultset("Artist")->count, 4, 'count ok'); diff --git a/t/run/05multipk.tl b/t/run/05multipk.tl index 776a382..e60f006 100644 --- a/t/run/05multipk.tl +++ b/t/run/05multipk.tl @@ -6,7 +6,7 @@ $artist = DBICTest::Artist->find(1); ok($artist->find_related('twokeys', {cd => 1}), "find multiple pks using relationships + args"); ok($schema->resultset("FourKeys")->find(1,2,3,4), "find multiple pks without hash"); ok($schema->resultset("FourKeys")->find(5,4,3,6), "find multiple pks without hash"); -is($schema->resultset("FourKeys")->find(1,2,3,4)->ID, 'DBICTest::FourKeys|bar=2|foo=1|goodbye=4|hello=3', 'unique object id ok for multiple pks'); +is($schema->resultset("FourKeys")->find(1,2,3,4)->ID, 'DBICTest::FourKeys|fourkeys|bar=2|foo=1|goodbye=4|hello=3', 'unique object id ok for multiple pks'); }