diff --git a/src/main/query/add_ops.c b/src/main/query/add_ops.c index 45b2c5d9c7..fcf2ce82bb 100644 --- a/src/main/query/add_ops.c +++ b/src/main/query/add_ops.c @@ -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. @@ -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."); diff --git a/src/main/query/select.c b/src/main/query/select.c index 66a4e73132..e89af55d6a 100644 --- a/src/main/query/select.c +++ b/src/main/query/select.c @@ -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; @@ -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"); diff --git a/src/main/scan/add_ops.c b/src/main/scan/add_ops.c index 3c72a8a8e9..2f4b517534 100644 --- a/src/main/scan/add_ops.c +++ b/src/main/scan/add_ops.c @@ -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. @@ -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."); diff --git a/src/main/scan/select.c b/src/main/scan/select.c index e794ae8963..6006bfaf68 100644 --- a/src/main/scan/select.c +++ b/src/main/scan/select.c @@ -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; @@ -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"); diff --git a/test/new_tests/test_query_bin_projection.py b/test/new_tests/test_query_bin_projection.py index cc54589065..a608443e47 100644 --- a/test/new_tests/test_query_bin_projection.py +++ b/test/new_tests/test_query_bin_projection.py @@ -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() @@ -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() diff --git a/test/new_tests/test_query_execute_background.py b/test/new_tests/test_query_execute_background.py index 7ea1b97dbf..483166a78d 100644 --- a/test/new_tests/test_query_execute_background.py +++ b/test/new_tests/test_query_execute_background.py @@ -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] @@ -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] diff --git a/test/new_tests/test_scan_execute_background.py b/test/new_tests/test_scan_execute_background.py index 1a90d90ca4..64a2767db4 100644 --- a/test/new_tests/test_scan_execute_background.py +++ b/test/new_tests/test_scan_execute_background.py @@ -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] @@ -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]