From: Matt S Trout Date: Sun, 10 Jan 2010 07:03:21 +0000 (+0000) Subject: don't overwrite cached object fields on fetch all since we can't guarantee that it... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b1c3fd5d20728018e1b8c4bcdd7ad0a17e047fb9;p=dbsrgits%2FDBIx-Data-Store-old.git don't overwrite cached object fields on fetch all since we can't guarantee that it's safe --- diff --git a/lib/DBIx/Data/Collection/Set.pm b/lib/DBIx/Data/Collection/Set.pm index ceb1e3f..1acf096 100644 --- a/lib/DBIx/Data/Collection/Set.pm +++ b/lib/DBIx/Data/Collection/Set.pm @@ -23,7 +23,7 @@ method _build__member_cache { while (my ($raw) = $stream->next) { my $obj = do { if (my ($obj) = $self->_key_cache_get_raw($raw)) { - $self->_merge($obj, $raw) + $obj # can't $self->_merge($obj, $raw) since $obj might have changed } else { $self->_add_to_key_cache($self->_inflate($raw)) } diff --git a/t/01basic_collection.t b/t/01basic_collection.t index c987036..9fded99 100644 --- a/t/01basic_collection.t +++ b/t/01basic_collection.t @@ -133,4 +133,8 @@ is($pterry->{name}, 'Sir Pterry', 'Pterry retrieved by id'); ok(!defined($set->get({ id => -1 })), 'undef on missing id'); +$pterry->{name} = 'Pterry'; + +is_deeply([ sort_set $set->flatten ], \@expect, 'Basic data after fetch by id'); + done_testing;