Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/main/query/add_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@
AerospikeQuery *AerospikeQuery_Add_Ops(AerospikeQuery *self, PyObject *args,
PyObject *kwds)
{
if (self->query.select.size) {
// If select() was called on this Query object before.

int retval = PyErr_WarnFormat(
PyExc_DeprecationWarning, STACK_LEVEL,
SELECT_AND_ADD_OPS_ARE_MUTUALLY_EXCLUSIVE_MESSAGE, "Query");
if (retval == -1) {
return NULL;
}
}

// Python function arguments.
PyObject *py_ops = NULL;
// Python function keyword arguments.
Expand All @@ -68,6 +57,14 @@ AerospikeQuery *AerospikeQuery_Add_Ops(AerospikeQuery *self, PyObject *args,
goto CLEANUP;
}

if (self->query.select.size) {
// If select() was called on this Query object before.
as_error_update(&err, AEROSPIKE_ERR_CLIENT,
SELECT_AND_ADD_OPS_ARE_MUTUALLY_EXCLUSIVE_MESSAGE,
"Query");
goto CLEANUP;
}

if (!self->client->is_conn_16) {
as_error_update(&err, AEROSPIKE_ERR_CLUSTER,
"No connection to aerospike cluster.");
Expand Down
18 changes: 8 additions & 10 deletions src/main/query/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ AerospikeQuery *AerospikeQuery_Select(AerospikeQuery *self, PyObject *args,
{
TRACE();

// If add_ops() was called on this Query object before.
if (as_operations_defined(self->query.ops)) {
int retval = PyErr_WarnFormat(
PyExc_DeprecationWarning, STACK_LEVEL,
SELECT_AND_ADD_OPS_ARE_MUTUALLY_EXCLUSIVE_MESSAGE, "Query");
if (retval == -1) {
return NULL;
}
}

int nbins = (int)PyTuple_Size(args);
char *bin = NULL;
PyObject *py_ubin = NULL;
Expand All @@ -61,6 +51,14 @@ AerospikeQuery *AerospikeQuery_Select(AerospikeQuery *self, PyObject *args,
goto CLEANUP;
}

// If add_ops() was called on this Query object before.
if (as_operations_defined(self->query.ops)) {
as_error_update(&err, AEROSPIKE_ERR_CLIENT,
SELECT_AND_ADD_OPS_ARE_MUTUALLY_EXCLUSIVE_MESSAGE,
"Query");
goto CLEANUP;
}

if (!self->client->is_conn_16) {
as_error_update(&err, AEROSPIKE_ERR_CLUSTER,
"No connection to aerospike cluster");
Expand Down
19 changes: 8 additions & 11 deletions src/main/scan/add_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@
AerospikeScan *AerospikeScan_Add_Ops(AerospikeScan *self, PyObject *args,
PyObject *kwds)
{
if (self->scan.select.size) {
// If select() was called on this Scan object before.

int retval = PyErr_WarnFormat(
PyExc_DeprecationWarning, STACK_LEVEL,
SELECT_AND_ADD_OPS_ARE_MUTUALLY_EXCLUSIVE_MESSAGE, "Scan");
if (retval == -1) {
return NULL;
}
}

// Python function arguments.
PyObject *py_ops = NULL;
// Python function keyword arguments.
Expand All @@ -68,6 +57,14 @@ AerospikeScan *AerospikeScan_Add_Ops(AerospikeScan *self, PyObject *args,
goto CLEANUP;
}

if (self->scan.select.size) {
// If select() was called on this Scan object before.
as_error_update(&err, AEROSPIKE_ERR_CLIENT,
SELECT_AND_ADD_OPS_ARE_MUTUALLY_EXCLUSIVE_MESSAGE,
"Scan");
goto CLEANUP;
}

if (!self->client->is_conn_16) {
as_error_update(&err, AEROSPIKE_ERR_CLUSTER,
"No connection to aerospike cluster.");
Expand Down
18 changes: 8 additions & 10 deletions src/main/scan/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ AerospikeScan *AerospikeScan_Select(AerospikeScan *self, PyObject *args,
{
TRACE();

// If add_ops() was called on this Scan object before.
if (as_operations_defined(self->scan.ops)) {
int retval = PyErr_WarnFormat(
PyExc_DeprecationWarning, STACK_LEVEL,
SELECT_AND_ADD_OPS_ARE_MUTUALLY_EXCLUSIVE_MESSAGE, "Scan");
if (retval == -1) {
return NULL;
}
}

char *bin = NULL;
PyObject *py_ustr = NULL;
as_error err;
Expand All @@ -59,6 +49,14 @@ AerospikeScan *AerospikeScan_Select(AerospikeScan *self, PyObject *args,
goto CLEANUP;
}

// If add_ops() was called on this Scan object before.
if (as_operations_defined(self->scan.ops)) {
as_error_update(&err, AEROSPIKE_ERR_CLIENT,
SELECT_AND_ADD_OPS_ARE_MUTUALLY_EXCLUSIVE_MESSAGE,
"Scan");
goto CLEANUP;
}

if (!self->client->is_conn_16) {
as_error_update(&err, AEROSPIKE_ERR_CLUSTER,
"No connection to aerospike cluster");
Expand Down
4 changes: 2 additions & 2 deletions test/new_tests/test_query_bin_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_add_write_ops_in_foreground_query(self, query, api_method, args, ops):

def test_select_bins_then_add_ops_then_foreground_query(self, query):
query.select(NON_EXISTENT_BIN_NAME)
with pytest.warns(DeprecationWarning):
with pytest.raises(e.ParamError):
query.add_ops(BASIC_READ_BIN_OPS)

records = query.results()
Expand All @@ -104,7 +104,7 @@ def test_select_bins_then_add_ops_then_foreground_query(self, query):

def test_add_ops_then_select_bins_then_foreground_query(self, query):
query.add_ops(BASIC_READ_BIN_OPS)
with pytest.warns(DeprecationWarning):
with pytest.raises(e.ParamError):
query.select(NON_EXISTENT_BIN_NAME)

records = query.results()
Expand Down
4 changes: 2 additions & 2 deletions test/new_tests/test_query_execute_background.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def test_add_read_ops(self, ops, query):

def test_select_bins_then_add_ops_then_bg_query(self, query):
query.select(NON_EXISTENT_BIN_NAME)
with pytest.warns(DeprecationWarning) as record:
with pytest.raises(exception.ParamError) as record:
query.add_ops(WRITE_OPS)
assert "Operations and bin names are mutually exclusive" in record[0].message.args[0]

Expand All @@ -375,7 +375,7 @@ def test_select_bins_then_add_ops_then_bg_query(self, query):

def test_add_ops_then_select_bins_then_bg_query(self, query):
query.add_ops(WRITE_OPS)
with pytest.warns(DeprecationWarning) as record:
with pytest.raises(exception.ParamError) as record:
query.select(NON_EXISTENT_BIN_NAME)
assert "Operations and bin names are mutually exclusive" in record[0].message.args[0]

Expand Down
4 changes: 2 additions & 2 deletions test/new_tests/test_scan_execute_background.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def test_add_read_ops(self, ops, scan_obj):

def test_select_bins_then_add_ops_then_bg_query(self, scan_obj):
scan_obj.select(NON_EXISTENT_BIN_NAME)
with pytest.warns(DeprecationWarning) as record:
with pytest.raises(exception.ParamError) as record:
scan_obj.add_ops(WRITE_OPS)
assert "Operations and bin names are mutually exclusive" in record[0].message.args[0]

Expand All @@ -368,7 +368,7 @@ def test_select_bins_then_add_ops_then_bg_query(self, scan_obj):

def test_add_ops_then_select_bins_then_bg_query(self, scan_obj):
scan_obj.add_ops(WRITE_OPS)
with pytest.warns(DeprecationWarning) as record:
with pytest.raises(exception.ParamError) as record:
scan_obj.select(NON_EXISTENT_BIN_NAME)
assert "Operations and bin names are mutually exclusive" in record[0].message.args[0]

Expand Down
Loading