Skip to content

Commit

Permalink
Merge pull request aerospike#141 from citrusleaf/CLIENT-697
Browse files Browse the repository at this point in the history
Don't raise RecordNotFound exception for exists() on nonexistent record
  • Loading branch information
Jeff Boone committed Mar 24, 2016
2 parents e4c9a47 + 33dffc9 commit b92e31d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 13 additions & 0 deletions src/main/client/exists.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ extern PyObject * AerospikeClient_Exists_Invoke(
py_result = PyTuple_New(2);
PyTuple_SetItem(py_result, 0, py_result_key);
PyTuple_SetItem(py_result, 1, py_result_meta);
} else if( err.code == AEROSPIKE_ERR_RECORD_NOT_FOUND ) {
as_error_reset(&err);

PyObject * py_result_key = NULL;
PyObject * py_result_meta = Py_None;

key_to_pyobject(&err, &key, &py_result_key);

py_result = PyTuple_New(2);
PyTuple_SetItem(py_result, 0, py_result_key);
PyTuple_SetItem(py_result, 1, py_result_meta);

Py_INCREF(py_result_meta);
}
else {
as_error_update(&err, err.code, NULL);
Expand Down
8 changes: 3 additions & 5 deletions test/new_tests/test_exists.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ def test_neg_exists_with_record_expiry(self, put_data):
policy = {'timeout': 1000}
put_data(self.as_connection, key, rec, meta, policy)
time.sleep(2)
try:
key, meta = self.as_connection.exists(key)
assert meta is None
except e.RecordNotFound as exception:
assert exception.code == 2

key, meta = self.as_connection.exists(key)
assert meta is None

@pytest.mark.parametrize("key, ex, ex_code", [
# reason for xfail CLIENT-533
Expand Down

0 comments on commit b92e31d

Please sign in to comment.