Skip to content

Commit

Permalink
Don't raise RecordNotFound exception for exists() on nonexistent record
Browse files Browse the repository at this point in the history
  • Loading branch information
jboone100 committed Mar 24, 2016
1 parent e4c9a47 commit 33dffc9
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 33dffc9

Please sign in to comment.