fixed EXISTS

This commit is contained in:
Kenichi Ishigaki 2013-07-04 13:40:10 +09:00
parent a94bdc6ca2
commit 879640f4c5
2 changed files with 4 additions and 2 deletions

View file

@ -139,9 +139,9 @@ sub NEXTKEY {
sub EXISTS { sub EXISTS {
my ($self, $key) = @_; my ($self, $key) = @_;
$self->[1]->kv_fetch($key); $self->[1]->kv_fetch($key) and return 1;
my $errstr = $self->[1]->errstr; my $errstr = $self->[1]->errstr;
return $errstr eq 'UNQLITE_NOTFOUND' ? 1 : 0; return $errstr && $errstr eq 'UNQLITE_OK' ? 1 : 0;
} }
sub CLEAR { sub CLEAR {

View file

@ -31,6 +31,8 @@ my $tmp = tempdir( CLEANUP => 1 );
$hash{delete} = 'delete'; $hash{delete} = 'delete';
is(delete $hash{delete}, 'delete'); is(delete $hash{delete}, 'delete');
is(delete $hash{delete}, undef); is(delete $hash{delete}, undef);
ok(exists $hash{foo});
ok(!exists $hash{delete});
is(join(" ", sort keys %hash), "foo yay"); is(join(" ", sort keys %hash), "foo yay");
is(join(" ", sort values %hash), "baz yappo"); is(join(" ", sort values %hash), "baz yappo");