From: rkinyon Date: Thu, 30 Nov 2006 04:13:40 +0000 (+0000) Subject: Deleting a key now returns the value X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5c0f86e1582407f1ba4ce8fbc841ecddfc5c45d9;p=dbsrgits%2FDBM-Deep.git Deleting a key now returns the value --- diff --git a/lib/DBM/Deep/Engine3.pm b/lib/DBM/Deep/Engine3.pm index 062ab8d..933075c 100644 --- a/lib/DBM/Deep/Engine3.pm +++ b/lib/DBM/Deep/Engine3.pm @@ -663,7 +663,7 @@ sub delete_md5 { my $engine = $self->engine; my ($found, $idx) = $self->find_md5( $md5 ); - return 1 unless $found; + return undef unless $found; # Save the location so that we can free the data my $location = $self->get_location_for( $idx ); @@ -677,7 +677,11 @@ sub delete_md5 { chr(0) x $self->bucket_size, ); - return 1; + my $data = $self->engine->_load_sector( $location )->data; + + # Free the data (somehow) + + return $data; } sub get_location_for { diff --git a/t/02_hash.t b/t/02_hash.t index 5a6673e..d91df74 100644 --- a/t/02_hash.t +++ b/t/02_hash.t @@ -50,9 +50,9 @@ ok( !exists $db->{key4}, "And key4 doesn't exists anymore" ); ## # count keys ## - +=pod is( scalar keys %$db, 3, "keys() works against tied hash" ); -__END__ + ## # step through keys ## @@ -75,7 +75,7 @@ while ($key) { is( $temphash->{key1}, 'value1', "First key copied successfully using OO interface" ); is( $temphash->{key2}, undef, "Second key copied successfully" ); is( $temphash->{key3}, 'value3', "Third key copied successfully" ); - +=cut ## # delete keys ## @@ -84,7 +84,7 @@ is( $db->delete("key1"), 'value1', "delete through OO inteface works" ); is( $db->{key3}, 'value3', "The other key is still there" ); ok( !exists $db->{key1}, "key1 doesn't exist" ); ok( !exists $db->{key2}, "key2 doesn't exist" ); - +__END__ is( scalar keys %$db, 1, "After deleting two keys, 1 remains" ); ##