diff --git a/lib/UnQLite.pm b/lib/UnQLite.pm index 3868d37..cabfda4 100644 --- a/lib/UnQLite.pm +++ b/lib/UnQLite.pm @@ -139,9 +139,9 @@ sub NEXTKEY { sub EXISTS { my ($self, $key) = @_; - $self->[1]->kv_fetch($key); + $self->[1]->kv_fetch($key) and return 1; my $errstr = $self->[1]->errstr; - return $errstr eq 'UNQLITE_NOTFOUND' ? 1 : 0; + return $errstr && $errstr eq 'UNQLITE_OK' ? 1 : 0; } sub CLEAR { diff --git a/t/03_tie.t b/t/03_tie.t index 9c66d6c..4d6d936 100644 --- a/t/03_tie.t +++ b/t/03_tie.t @@ -31,6 +31,8 @@ my $tmp = tempdir( CLEANUP => 1 ); $hash{delete} = 'delete'; is(delete $hash{delete}, 'delete'); is(delete $hash{delete}, undef); + ok(exists $hash{foo}); + ok(!exists $hash{delete}); is(join(" ", sort keys %hash), "foo yay"); is(join(" ", sort values %hash), "baz yappo");