From 0cc611b846dd5f1147dbdbac6f050f2c4c3f91ad Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 27 Aug 2025 11:14:49 -0700 Subject: [PATCH 01/25] Fix command-level write, operate, batch_write, and scan policies not accepting ttl as an option --- src/main/policy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/policy.c b/src/main/policy.c index 0b91e1066e..c3cb3affea 100644 --- a/src/main/policy.c +++ b/src/main/policy.c @@ -552,6 +552,7 @@ as_status pyobject_to_policy_scan(AerospikeClient *self, as_error *err, POLICY_SET_FIELD(records_per_second, uint32_t); POLICY_SET_FIELD(max_records, uint64_t); POLICY_SET_FIELD(replica, as_policy_replica); + POLICY_SET_FIELD(ttl, uint32_t); } // Update the policy @@ -593,6 +594,7 @@ as_status pyobject_to_policy_write(AerospikeClient *self, as_error *err, POLICY_SET_FIELD(commit_level, as_policy_commit_level); POLICY_SET_FIELD(durable_delete, bool); POLICY_SET_FIELD(replica, as_policy_replica); + POLICY_SET_FIELD(ttl, uint32_t); POLICY_SET_FIELD(compression_threshold, uint32_t); POLICY_SET_FIELD(on_locking_only, bool); } @@ -640,6 +642,7 @@ as_status pyobject_to_policy_operate(AerospikeClient *self, as_error *err, POLICY_SET_FIELD(exists, as_policy_exists); POLICY_SET_FIELD(read_touch_ttl_percent, int); POLICY_SET_FIELD(on_locking_only, bool); + POLICY_SET_FIELD(ttl, uint32_t); // 4.0.0 new policies POLICY_SET_FIELD(read_mode_ap, as_policy_read_mode_ap); @@ -716,6 +719,7 @@ as_status pyobject_to_batch_write_policy(AerospikeClient *self, as_error *err, POLICY_SET_FIELD(exists, as_policy_exists); POLICY_SET_FIELD(durable_delete, bool); POLICY_SET_FIELD(on_locking_only, bool); + POLICY_SET_FIELD(ttl, uint32_t); // C client 5.0 new expressions POLICY_SET_EXPRESSIONS_FIELD(); From 7eaaa1f0a2e2241cd3978c91c05efc9aa9280712 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 27 Aug 2025 11:40:23 -0700 Subject: [PATCH 02/25] Deprecate meta parameter in client.put() --- doc/client.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/client.rst b/doc/client.rst index da697eb05c..aac32aff22 100755 --- a/doc/client.rst +++ b/doc/client.rst @@ -102,7 +102,8 @@ Record Commands :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param dict bins: contains bin name-value pairs of the record. - :param dict meta: record metadata to be set. see :ref:`metadata_dict`. + :param dict meta: record metadata to be set. see :ref:`metadata_dict`. .. deprecated:: 17.2.0 Use the write policy to set ``ttl`` and ``gen`` instead. + :param dict policy: see :ref:`aerospike_write_policies`. :param serializer: override the serialization mode of the client \ From 521e2157bdc71cbb4e2e90394d4989f3b7fb37c2 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 27 Aug 2025 11:44:10 -0700 Subject: [PATCH 03/25] fix? --- doc/client.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/client.rst b/doc/client.rst index aac32aff22..120dbb0b9a 100755 --- a/doc/client.rst +++ b/doc/client.rst @@ -102,8 +102,8 @@ Record Commands :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param dict bins: contains bin name-value pairs of the record. - :param dict meta: record metadata to be set. see :ref:`metadata_dict`. .. deprecated:: 17.2.0 Use the write policy to set ``ttl`` and ``gen`` instead. - + :param dict meta: record metadata to be set. see :ref:`metadata_dict`. + .. deprecated:: 17.2.0 Use the write policy to set ``ttl`` and ``gen`` instead. :param dict policy: see :ref:`aerospike_write_policies`. :param serializer: override the serialization mode of the client \ From 915678e8bdbaa490b9aeae79b22310e8ac724792 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 27 Aug 2025 12:43:42 -0700 Subject: [PATCH 04/25] fix? --- doc/client.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/client.rst b/doc/client.rst index 120dbb0b9a..c636568720 100755 --- a/doc/client.rst +++ b/doc/client.rst @@ -103,7 +103,10 @@ Record Commands :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param dict bins: contains bin name-value pairs of the record. :param dict meta: record metadata to be set. see :ref:`metadata_dict`. - .. deprecated:: 17.2.0 Use the write policy to set ``ttl`` and ``gen`` instead. + + .. deprecated:: 17.2.0 + Use the write policy to set ``ttl`` and ``gen`` instead. + :param dict policy: see :ref:`aerospike_write_policies`. :param serializer: override the serialization mode of the client \ From 48453a9890feac4d3da4ac6254f053b4dd7fa92d Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 27 Aug 2025 12:44:46 -0700 Subject: [PATCH 05/25] fix? --- doc/client.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/client.rst b/doc/client.rst index c636568720..4fb411dbe6 100755 --- a/doc/client.rst +++ b/doc/client.rst @@ -102,7 +102,8 @@ Record Commands :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param dict bins: contains bin name-value pairs of the record. - :param dict meta: record metadata to be set. see :ref:`metadata_dict`. + :param dict meta: + record metadata to be set. see :ref:`metadata_dict`. .. deprecated:: 17.2.0 Use the write policy to set ``ttl`` and ``gen`` instead. From 0e2032c7f4045d79ce9944fbe1b2e4e4bfa87aff Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 27 Aug 2025 13:24:08 -0700 Subject: [PATCH 06/25] fix client.remove_bin() not applying policy's ttl if meta.ttl is set to aerospike.TTL_CLIENT_DEFAULT --- src/main/client/remove_bin.c | 59 ++++++++++++------------------------ 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/src/main/client/remove_bin.c b/src/main/client/remove_bin.c index 1444f57473..aa405a8597 100644 --- a/src/main/client/remove_bin.c +++ b/src/main/client/remove_bin.c @@ -83,6 +83,19 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, } // Invoke operation + // TODO: check for mem leak from policy + PyObject *py_bins = PyDict_New(); + if (py_bins) { + goto CLEANUP; + } + + // Serializer option doesn't matter since we're just deleting bins + // static_pool isn't used since the bin dictionary is guaranteed to be empty + as_record_init_from_pyobject(self, err, py_bins, py_meta, &rec, + SERIALIZER_NONE, NULL); + if (err->code != AEROSPIKE_OK) { + goto CLEANUP; + } for (count = 0; count < size; count++) { PyObject *py_val = PyList_GetItem(py_binList, count); @@ -93,9 +106,11 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, else { as_error_update(err, AEROSPIKE_ERR_CLIENT, "Invalid bin name, bin name should be a string or " - "unicode string") goto CLEANUP; + "unicode string"); + goto CLEANUP; } if (!as_record_set_nil(&rec, binName)) { + // TODO: mem leak goto CLEANUP; } if (py_ustr) { @@ -104,45 +119,6 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, } } - if (py_meta && PyDict_Check(py_meta)) { - PyObject *py_gen = PyDict_GetItemString(py_meta, "gen"); - PyObject *py_ttl = PyDict_GetItemString(py_meta, "ttl"); - - if (py_ttl) { - if (PyLong_Check(py_ttl)) { - rec.ttl = (uint32_t)PyLong_AsLong(py_ttl); - if ((uint32_t)-1 == rec.ttl && PyErr_Occurred()) { - as_error_update( - err, AEROSPIKE_ERR_PARAM, - "integer value for ttl exceeds sys.maxsize"); - goto CLEANUP; - } - } - else { - as_error_update(err, AEROSPIKE_ERR_PARAM, - "Ttl should be an int or long"); - goto CLEANUP; - } - } - - if (py_gen) { - if (PyLong_Check(py_gen)) { - rec.gen = (uint16_t)PyLong_AsLongLong(py_gen); - if ((uint16_t)-1 == rec.gen && PyErr_Occurred()) { - as_error_update( - err, AEROSPIKE_ERR_PARAM, - "integer value for gen exceeds sys.maxsize"); - goto CLEANUP; - } - } - else { - as_error_update(err, AEROSPIKE_ERR_PARAM, - "Generation should be an int or long"); - goto CLEANUP; - } - } - } - Py_BEGIN_ALLOW_THREADS aerospike_key_put(self->as, err, write_policy_p, &key, &rec); Py_END_ALLOW_THREADS @@ -163,6 +139,9 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, raise_exception_base(err, py_key, Py_None, Py_None, Py_None, Py_None); return NULL; } + else if (PyErr_Occurred()) { + return NULL; + } return PyLong_FromLong(0); } From 138358f63016c8aeaa6dc71a003be5b63a5fae29 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 27 Aug 2025 13:28:27 -0700 Subject: [PATCH 07/25] dont init as_record twice --- src/main/client/remove_bin.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/client/remove_bin.c b/src/main/client/remove_bin.c index aa405a8597..1b9decafab 100644 --- a/src/main/client/remove_bin.c +++ b/src/main/client/remove_bin.c @@ -63,8 +63,6 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, // Get the bin list size; Py_ssize_t size = PyList_Size(py_binList); - // Initialize record - as_record_inita(&rec, size); // Convert python key object to as_key pyobject_to_key(err, py_key, &key); From 1b0c36f30d4c36dd6a6a79b0d5cbc9dcadc781d5 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 27 Aug 2025 13:38:37 -0700 Subject: [PATCH 08/25] put() is also initializing as_record twice --- src/main/client/put.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/client/put.c b/src/main/client/put.c index fa7910bb79..355b3074f4 100644 --- a/src/main/client/put.c +++ b/src/main/client/put.c @@ -62,10 +62,6 @@ PyObject *AerospikeClient_Put_Invoke(AerospikeClient *self, PyObject *py_key, bool key_initialised = false; bool record_initialised = false; - // Initialize record - as_record_init(&rec, 0); - record_initialised = true; - as_static_pool static_pool; memset(&static_pool, 0, sizeof(static_pool)); @@ -94,6 +90,8 @@ PyObject *AerospikeClient_Put_Invoke(AerospikeClient *self, PyObject *py_key, // Convert python bins and metadata objects to as_record as_record_init_from_pyobject(self, &err, py_bins, py_meta, &rec, serializer_option, &static_pool); + // Initialize record + record_initialised = true; if (err.code != AEROSPIKE_OK) { goto CLEANUP; } From 5062f5cdf40cd5fe1b7755eb84e7403ace64084b Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 27 Aug 2025 13:47:39 -0700 Subject: [PATCH 09/25] hard to deprecate function params. just add a note in function --- doc/client.rst | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/client.rst b/doc/client.rst index 4fb411dbe6..b23a731889 100755 --- a/doc/client.rst +++ b/doc/client.rst @@ -100,14 +100,12 @@ Record Commands Create a new record, or remove / add bins to a record. + .. versionchanged:: 17.2.0 + Deprecated the ``meta`` parameter. Use the write policy to set ``ttl`` and ``gen`` instead. + :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param dict bins: contains bin name-value pairs of the record. - :param dict meta: - record metadata to be set. see :ref:`metadata_dict`. - - .. deprecated:: 17.2.0 - Use the write policy to set ``ttl`` and ``gen`` instead. - + :param dict meta: Deprecated: record metadata to be set. see :ref:`metadata_dict`. :param dict policy: see :ref:`aerospike_write_policies`. :param serializer: override the serialization mode of the client \ From 1ca626ecf17abc8d9f3474205f60fe0c3eafbe21 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 27 Aug 2025 14:10:13 -0700 Subject: [PATCH 10/25] fix mem leak if bins dictionary is invalid --- src/main/client/put.c | 2 +- src/main/client/remove_bin.c | 6 +++++- src/main/conversions.c | 27 ++++++++++++++++----------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/main/client/put.c b/src/main/client/put.c index 355b3074f4..6e369128b1 100644 --- a/src/main/client/put.c +++ b/src/main/client/put.c @@ -91,10 +91,10 @@ PyObject *AerospikeClient_Put_Invoke(AerospikeClient *self, PyObject *py_key, as_record_init_from_pyobject(self, &err, py_bins, py_meta, &rec, serializer_option, &static_pool); // Initialize record - record_initialised = true; if (err.code != AEROSPIKE_OK) { goto CLEANUP; } + record_initialised = true; // Convert python policy object to as_policy_write pyobject_to_policy_write(self, &err, py_policy, &write_policy, diff --git a/src/main/client/remove_bin.c b/src/main/client/remove_bin.c index 1b9decafab..655cba60f0 100644 --- a/src/main/client/remove_bin.c +++ b/src/main/client/remove_bin.c @@ -56,6 +56,7 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, char *binName = NULL; int count = 0; PyObject *py_ustr = NULL; + bool record_initialised = false; // For converting expressions. as_exp exp_list; @@ -94,6 +95,7 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, if (err->code != AEROSPIKE_OK) { goto CLEANUP; } + record_initialised = true; for (count = 0; count < size; count++) { PyObject *py_val = PyList_GetItem(py_binList, count); @@ -123,7 +125,9 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, CLEANUP: - as_record_destroy(&rec); + if (record_initialised) { + as_record_destroy(&rec); + } if (exp_list_p) { as_exp_destroy(exp_list_p); diff --git a/src/main/conversions.c b/src/main/conversions.c index 142dc485d2..d3889d5227 100644 --- a/src/main/conversions.c +++ b/src/main/conversions.c @@ -1347,6 +1347,7 @@ as_status as_record_init_from_pyobject(AerospikeClient *self, as_error *err, // this should never happen, but if it did... return as_error_update(err, AEROSPIKE_ERR_CLIENT, "record is null"); } + else if (PyDict_Check(py_bins_dict)) { PyObject *py_bin_name = NULL, *py_bin_value = NULL; Py_ssize_t pos = 0; @@ -1356,32 +1357,33 @@ as_status as_record_init_from_pyobject(AerospikeClient *self, as_error *err, as_record_init(rec, size); while (PyDict_Next(py_bins_dict, &pos, &py_bin_name, &py_bin_value)) { - if (!PyUnicode_Check(py_bin_name)) { - return as_error_update( + as_error_update( err, AEROSPIKE_ERR_CLIENT, "A bin name must be a string or unicode string."); + goto CLEANUP_ON_ERROR; } name = PyUnicode_AsUTF8(py_bin_name); if (!name) { - return as_error_update( - err, AEROSPIKE_ERR_CLIENT, - "Unable to convert unicode object to C string"); + as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Unable to convert unicode object to C string"); + goto CLEANUP_ON_ERROR; } if (self->strict_types) { if (strlen(name) > AS_BIN_NAME_MAX_LEN) { - return as_error_update( + as_error_update( err, AEROSPIKE_ERR_BIN_NAME, "A bin name should not exceed 15 characters limit"); + goto CLEANUP_ON_ERROR; } } if (!py_bin_value) { // this should never happen, but if it did... - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "record is null"); + as_error_update(err, AEROSPIKE_ERR_CLIENT, "record is null"); + goto CLEANUP_ON_ERROR; } as_val *val = NULL; @@ -1393,8 +1395,9 @@ as_status as_record_init_from_pyobject(AerospikeClient *self, as_error *err, bool success = as_record_set(rec, name, (as_bin_value *)val); if (success == false) { as_val_destroy(val); - return as_error_update(err, AEROSPIKE_ERR_BIN_NAME, - "Unable to set key-value pair"); + as_error_update(err, AEROSPIKE_ERR_BIN_NAME, + "Unable to set key-value pair"); + goto CLEANUP_ON_ERROR; } } @@ -1451,7 +1454,7 @@ as_status as_record_init_from_pyobject(AerospikeClient *self, as_error *err, } if (err->code != AEROSPIKE_OK) { - as_record_destroy(rec); + goto CLEANUP_ON_ERROR; } } else { @@ -1459,6 +1462,8 @@ as_status as_record_init_from_pyobject(AerospikeClient *self, as_error *err, "Record should be passed as bin-value pair"); } +CLEANUP_ON_ERROR: + as_record_destroy(rec); return err->code; } From 33907e117539d6803bec48a84b03aae70c1f2a79 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Thu, 28 Aug 2025 16:46:47 -0700 Subject: [PATCH 11/25] revert --- src/main/client/put.c | 6 ++-- src/main/client/remove_bin.c | 67 +++++++++++++++++++++++------------- 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/src/main/client/put.c b/src/main/client/put.c index 6e369128b1..fa7910bb79 100644 --- a/src/main/client/put.c +++ b/src/main/client/put.c @@ -62,6 +62,10 @@ PyObject *AerospikeClient_Put_Invoke(AerospikeClient *self, PyObject *py_key, bool key_initialised = false; bool record_initialised = false; + // Initialize record + as_record_init(&rec, 0); + record_initialised = true; + as_static_pool static_pool; memset(&static_pool, 0, sizeof(static_pool)); @@ -90,11 +94,9 @@ PyObject *AerospikeClient_Put_Invoke(AerospikeClient *self, PyObject *py_key, // Convert python bins and metadata objects to as_record as_record_init_from_pyobject(self, &err, py_bins, py_meta, &rec, serializer_option, &static_pool); - // Initialize record if (err.code != AEROSPIKE_OK) { goto CLEANUP; } - record_initialised = true; // Convert python policy object to as_policy_write pyobject_to_policy_write(self, &err, py_policy, &write_policy, diff --git a/src/main/client/remove_bin.c b/src/main/client/remove_bin.c index 655cba60f0..1444f57473 100644 --- a/src/main/client/remove_bin.c +++ b/src/main/client/remove_bin.c @@ -56,7 +56,6 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, char *binName = NULL; int count = 0; PyObject *py_ustr = NULL; - bool record_initialised = false; // For converting expressions. as_exp exp_list; @@ -64,6 +63,8 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, // Get the bin list size; Py_ssize_t size = PyList_Size(py_binList); + // Initialize record + as_record_inita(&rec, size); // Convert python key object to as_key pyobject_to_key(err, py_key, &key); @@ -82,20 +83,6 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, } // Invoke operation - // TODO: check for mem leak from policy - PyObject *py_bins = PyDict_New(); - if (py_bins) { - goto CLEANUP; - } - - // Serializer option doesn't matter since we're just deleting bins - // static_pool isn't used since the bin dictionary is guaranteed to be empty - as_record_init_from_pyobject(self, err, py_bins, py_meta, &rec, - SERIALIZER_NONE, NULL); - if (err->code != AEROSPIKE_OK) { - goto CLEANUP; - } - record_initialised = true; for (count = 0; count < size; count++) { PyObject *py_val = PyList_GetItem(py_binList, count); @@ -106,11 +93,9 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, else { as_error_update(err, AEROSPIKE_ERR_CLIENT, "Invalid bin name, bin name should be a string or " - "unicode string"); - goto CLEANUP; + "unicode string") goto CLEANUP; } if (!as_record_set_nil(&rec, binName)) { - // TODO: mem leak goto CLEANUP; } if (py_ustr) { @@ -119,15 +104,52 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, } } + if (py_meta && PyDict_Check(py_meta)) { + PyObject *py_gen = PyDict_GetItemString(py_meta, "gen"); + PyObject *py_ttl = PyDict_GetItemString(py_meta, "ttl"); + + if (py_ttl) { + if (PyLong_Check(py_ttl)) { + rec.ttl = (uint32_t)PyLong_AsLong(py_ttl); + if ((uint32_t)-1 == rec.ttl && PyErr_Occurred()) { + as_error_update( + err, AEROSPIKE_ERR_PARAM, + "integer value for ttl exceeds sys.maxsize"); + goto CLEANUP; + } + } + else { + as_error_update(err, AEROSPIKE_ERR_PARAM, + "Ttl should be an int or long"); + goto CLEANUP; + } + } + + if (py_gen) { + if (PyLong_Check(py_gen)) { + rec.gen = (uint16_t)PyLong_AsLongLong(py_gen); + if ((uint16_t)-1 == rec.gen && PyErr_Occurred()) { + as_error_update( + err, AEROSPIKE_ERR_PARAM, + "integer value for gen exceeds sys.maxsize"); + goto CLEANUP; + } + } + else { + as_error_update(err, AEROSPIKE_ERR_PARAM, + "Generation should be an int or long"); + goto CLEANUP; + } + } + } + Py_BEGIN_ALLOW_THREADS aerospike_key_put(self->as, err, write_policy_p, &key, &rec); Py_END_ALLOW_THREADS CLEANUP: - if (record_initialised) { - as_record_destroy(&rec); - } + as_record_destroy(&rec); if (exp_list_p) { as_exp_destroy(exp_list_p); @@ -141,9 +163,6 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key, raise_exception_base(err, py_key, Py_None, Py_None, Py_None, Py_None); return NULL; } - else if (PyErr_Occurred()) { - return NULL; - } return PyLong_FromLong(0); } From 9422ad2094aefe5fddb2f4f0af01a6eb558e7766 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 4 Nov 2025 08:00:34 -0800 Subject: [PATCH 12/25] Replace deprecation docstring with multiline var --- doc/client.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/client.rst b/doc/client.rst index fcbbc2149a..cdded13739 100755 --- a/doc/client.rst +++ b/doc/client.rst @@ -90,6 +90,10 @@ Connection You may call :meth:`~aerospike.Client.connect` again after closing the connection. +.. |deprecate_meta_docstring| replace:: + .. versionchanged:: 18.1.0 + Deprecated the ``meta`` parameter. Use the write policy to set ``ttl`` and ``gen`` instead. + Record Commands --------------- @@ -100,8 +104,7 @@ Record Commands Create a new record, or remove / add bins to a record. - .. versionchanged:: 17.2.0 - Deprecated the ``meta`` parameter. Use the write policy to set ``ttl`` and ``gen`` instead. + |deprecate_meta_docstring| :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param dict bins: contains bin name-value pairs of the record. @@ -255,6 +258,8 @@ Record Commands Remove a list of bins from a record with a given *key*. Equivalent to \ setting those bins to :meth:`aerospike.null` with a :meth:`~aerospike.put`. + |deprecate_meta_docstring| + :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param list list: the bins names to be removed from the record. :param dict meta: record metadata to be set. See :ref:`metadata_dict`. From add81e64a7f00df183cc5ef5c1feed515e00e038 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 4 Nov 2025 08:06:41 -0800 Subject: [PATCH 13/25] fix --- doc/client.rst | 8 ++------ doc/deprecate_meta.rst | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 doc/deprecate_meta.rst diff --git a/doc/client.rst b/doc/client.rst index cdded13739..c118fa247f 100755 --- a/doc/client.rst +++ b/doc/client.rst @@ -90,10 +90,6 @@ Connection You may call :meth:`~aerospike.Client.connect` again after closing the connection. -.. |deprecate_meta_docstring| replace:: - .. versionchanged:: 18.1.0 - Deprecated the ``meta`` parameter. Use the write policy to set ``ttl`` and ``gen`` instead. - Record Commands --------------- @@ -104,7 +100,7 @@ Record Commands Create a new record, or remove / add bins to a record. - |deprecate_meta_docstring| + .. include:: ./deprecate_meta.rst :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param dict bins: contains bin name-value pairs of the record. @@ -258,7 +254,7 @@ Record Commands Remove a list of bins from a record with a given *key*. Equivalent to \ setting those bins to :meth:`aerospike.null` with a :meth:`~aerospike.put`. - |deprecate_meta_docstring| + .. include:: ./deprecate_meta.rst :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param list list: the bins names to be removed from the record. diff --git a/doc/deprecate_meta.rst b/doc/deprecate_meta.rst new file mode 100644 index 0000000000..e1460e64df --- /dev/null +++ b/doc/deprecate_meta.rst @@ -0,0 +1,3 @@ +.. versionchanged:: 18.1.0 + + Deprecated the ``meta`` parameter. Use the write policy to set ``ttl`` and ``gen`` instead. From 826a9146b18665325625e94b680cc0689c17b1e3 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 5 Dec 2025 14:03:47 -0800 Subject: [PATCH 14/25] WIP --- src/main/client/operate.c | 14 ++++++++++++++ src/main/client/put.c | 7 +++++++ src/main/client/remove.c | 7 +++++++ src/main/client/remove_bin.c | 7 +++++++ test/new_tests/test_append.py | 7 ++++++- 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/main/client/operate.c b/src/main/client/operate.c index 2910558c8a..cd53d144d9 100644 --- a/src/main/client/operate.c +++ b/src/main/client/operate.c @@ -926,6 +926,13 @@ static PyObject *AerospikeClient_Operate_Invoke(AerospikeClient *self, as_exp exp_list; as_exp *exp_list_p = NULL; + if (py_meta) { + PyErr_WarnEx(PyExc_DeprecationWarning, + "meta parameter is deprecated and will be removed in the " + "next client major release.", + 2); + } + as_vector *unicodeStrVector = as_vector_create(sizeof(char *), 128); as_operations ops; @@ -1264,6 +1271,13 @@ PyObject *AerospikeClient_OperateOrdered(AerospikeClient *self, PyObject *args, return NULL; } + if (py_meta) { + PyErr_WarnEx(PyExc_DeprecationWarning, + "meta parameter is deprecated and will be removed in the " + "next client major release.", + 2); + } + CHECK_CONNECTED(&err); if (pyobject_to_key(&err, py_key, &key) != AEROSPIKE_OK) { diff --git a/src/main/client/put.c b/src/main/client/put.c index 4822b0d670..339d3df24e 100644 --- a/src/main/client/put.c +++ b/src/main/client/put.c @@ -168,6 +168,13 @@ PyObject *AerospikeClient_Put(AerospikeClient *self, PyObject *args, return NULL; } + if (py_meta) { + PyErr_WarnEx(PyExc_DeprecationWarning, + "meta parameter is deprecated and will be removed in the " + "next client major release.", + 2); + } + if (py_serializer_option) { if (PyLong_Check(py_serializer_option)) { self->is_client_put_serializer = true; diff --git a/src/main/client/remove.c b/src/main/client/remove.c index 0b76b6b358..e55b2c5c11 100644 --- a/src/main/client/remove.c +++ b/src/main/client/remove.c @@ -170,6 +170,13 @@ PyObject *AerospikeClient_Remove(AerospikeClient *self, PyObject *args, return NULL; } + if (py_meta) { + PyErr_WarnEx(PyExc_DeprecationWarning, + "meta parameter is deprecated and will be removed in the " + "next client major release.", + 2); + } + // Invoke Operation return AerospikeClient_Remove_Invoke(self, py_key, py_meta, py_policy); } diff --git a/src/main/client/remove_bin.c b/src/main/client/remove_bin.c index 0451d534b2..56faef8534 100644 --- a/src/main/client/remove_bin.c +++ b/src/main/client/remove_bin.c @@ -168,6 +168,13 @@ PyObject *AerospikeClient_RemoveBin(AerospikeClient *self, PyObject *args, return NULL; } + if (py_meta) { + PyErr_WarnEx(PyExc_DeprecationWarning, + "meta parameter is deprecated and will be removed in the " + "next client major release.", + 2); + } + if (!self || !self->as) { as_error_update(&err, AEROSPIKE_ERR_PARAM, "Invalid aerospike object"); goto CLEANUP; diff --git a/test/new_tests/test_append.py b/test/new_tests/test_append.py index bf0a4cbbef..f5082da5d4 100644 --- a/test/new_tests/test_append.py +++ b/test/new_tests/test_append.py @@ -4,6 +4,7 @@ from aerospike import exception as e import aerospike +import warnings # @pytest.mark.usefixtures("as_connection") @@ -116,7 +117,11 @@ def test_pos_append_with_policy_key_gen_EQ_ignore(self): } meta = {"gen": 10, "ttl": 1200} - self.as_connection.append(key, "name", "str", meta, policy) + with warnings.catch_warnings(record=True) as warning_list: + self.as_connection.append(key, "name", "str", meta, policy) + + assert len(warning_list) == 1 + assert warning_list[0].category == DeprecationWarning (key, meta, bins) = self.as_connection.get(key) From b4809d72f01a31fc8dabec0a7143d357fe3029da Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 5 Dec 2025 14:31:47 -0800 Subject: [PATCH 15/25] Revert --- src/main/policy.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/policy.c b/src/main/policy.c index d020ce21bb..e65baf4239 100644 --- a/src/main/policy.c +++ b/src/main/policy.c @@ -674,7 +674,6 @@ as_status pyobject_to_policy_scan( POLICY_SET_FIELD(records_per_second, uint32_t); POLICY_SET_FIELD(max_records, uint64_t); POLICY_SET_FIELD(replica, as_policy_replica); - POLICY_SET_FIELD(ttl, uint32_t); } // Update the policy @@ -737,7 +736,6 @@ as_status pyobject_to_policy_write( POLICY_SET_FIELD(commit_level, as_policy_commit_level); POLICY_SET_FIELD(durable_delete, bool); POLICY_SET_FIELD(replica, as_policy_replica); - POLICY_SET_FIELD(ttl, uint32_t); POLICY_SET_FIELD(compression_threshold, uint32_t); POLICY_SET_FIELD(on_locking_only, bool); } @@ -798,7 +796,6 @@ as_status pyobject_to_policy_operate(AerospikeClient *self, as_error *err, POLICY_SET_FIELD(exists, as_policy_exists); POLICY_SET_FIELD(read_touch_ttl_percent, int); POLICY_SET_FIELD(on_locking_only, bool); - POLICY_SET_FIELD(ttl, uint32_t); // 4.0.0 new policies POLICY_SET_FIELD(read_mode_ap, as_policy_read_mode_ap); @@ -902,7 +899,6 @@ as_status pyobject_to_batch_write_policy(AerospikeClient *self, as_error *err, POLICY_SET_FIELD(exists, as_policy_exists); POLICY_SET_FIELD(durable_delete, bool); POLICY_SET_FIELD(on_locking_only, bool); - POLICY_SET_FIELD(ttl, uint32_t); // C client 5.0 new expressions POLICY_SET_EXPRESSIONS_FIELD(); From e02c60ca801e412b4baae4ed1039394e79d2d558 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 5 Dec 2025 14:58:07 -0800 Subject: [PATCH 16/25] Doc --- doc/client.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/client.rst b/doc/client.rst index 8904cd406c..bb43862994 100755 --- a/doc/client.rst +++ b/doc/client.rst @@ -183,6 +183,8 @@ Record Commands (In Aerospike server versions prior to 3.6.0, non-existent bins being read will have a \ :py:obj:`None` value. ) + .. include:: ./deprecate_meta.rst + :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param list list: See :ref:`aerospike_operation_helpers.operations`. :param dict meta: record metadata to be set. See :ref:`metadata_dict`. @@ -209,6 +211,8 @@ Record Commands Write operations or read operations that fail will not return a ``(bin-name, result)`` tuple. + .. include:: ./deprecate_meta.rst + :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param list list: See :ref:`aerospike_operation_helpers.operations`. :param dict meta: record metadata to be set. See :ref:`metadata_dict`. @@ -226,6 +230,8 @@ Record Commands Touch the given record, setting its time-to-live and incrementing its generation. + .. include:: ./deprecate_meta.rst + :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param int val: ttl in seconds, with ``0`` resolving to the default value in the server config. :param dict meta: record metadata to be set. see :ref:`metadata_dict` @@ -240,6 +246,8 @@ Record Commands Remove a record matching the *key* from the cluster. + .. include:: ./deprecate_meta.rst + :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param dict meta: contains the expected generation of the record in a key called ``"gen"``. :param dict policy: see :ref:`aerospike_remove_policies`. May be passed as a keyword argument. @@ -412,6 +420,8 @@ String Operations Append a string to the string value in bin. + .. include:: ./deprecate_meta.rst + :param tuple key: a :ref:`aerospike_key_tuple` tuple associated with the record. :param str bin: the name of the bin. :param str val: the string to append to the bin value. @@ -431,6 +441,8 @@ String Operations Prepend the string value in *bin* with the string *val*. + .. include:: ./deprecate_meta.rst + :param tuple key: a :ref:`aerospike_key_tuple` tuple associated with the record. :param str bin: the name of the bin. :param str val: the string to prepend to the bin value. @@ -460,6 +472,8 @@ Numeric Operations Increment the integer value in *bin* by the integer *val*. + .. include:: ./deprecate_meta.rst + :param tuple key: a :ref:`aerospike_key_tuple` tuple associated with the record. :param str bin: the name of the bin. :param int offset: the value by which to increment the value in *bin*. From fa973ae8f6ecbd85cbf94f712ca91badbf8576e5 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 5 Dec 2025 15:00:29 -0800 Subject: [PATCH 17/25] test and see if deprecation shows up properly for aerospike_helpers. --- aerospike_helpers/batch/records.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aerospike_helpers/batch/records.py b/aerospike_helpers/batch/records.py index 99e9f5816e..53331d8cd8 100644 --- a/aerospike_helpers/batch/records.py +++ b/aerospike_helpers/batch/records.py @@ -60,6 +60,8 @@ def __init__(self, key: tuple) -> None: class Write(BatchRecord): """ Write is used for executing Batch write commands with batch_write and retrieving batch write results. + .. include:: ./deprecate_meta.rst + Attributes: key (:obj:`tuple`): The aerospike key to send the command to. record (:obj:`tuple`): The record corresponding to the requested key. From 4f649fe54c15b25f8ae777baa72ff5c8bdaa61ff Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 5 Dec 2025 15:07:00 -0800 Subject: [PATCH 18/25] Make more accurate for other commands that don't take in a write policy --- doc/deprecate_meta.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/deprecate_meta.rst b/doc/deprecate_meta.rst index e1460e64df..e721c10750 100644 --- a/doc/deprecate_meta.rst +++ b/doc/deprecate_meta.rst @@ -1,3 +1,3 @@ .. versionchanged:: 18.1.0 - Deprecated the ``meta`` parameter. Use the write policy to set ``ttl`` and ``gen`` instead. + Deprecated the ``meta`` parameter. Use the policy parameter to set ``ttl`` and ``gen`` instead. From d34d940f3e103854c3467002afefb6f714ac0779 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 5 Dec 2025 15:10:55 -0800 Subject: [PATCH 19/25] Finish updating aerospike_helpers --- aerospike_helpers/batch/records.py | 2 ++ aerospike_helpers/operations/operations.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/aerospike_helpers/batch/records.py b/aerospike_helpers/batch/records.py index 53331d8cd8..7de31879c9 100644 --- a/aerospike_helpers/batch/records.py +++ b/aerospike_helpers/batch/records.py @@ -113,6 +113,8 @@ def __init__( class Read(BatchRecord): """ Read is used for executing Batch read commands with batch_write and retrieving results. + .. include:: ./deprecate_meta.rst + Attributes: key (:obj:`tuple`): The aerospike key to send the command to. record (:obj:`tuple`): The record corresponding to the requested key. diff --git a/aerospike_helpers/operations/operations.py b/aerospike_helpers/operations/operations.py index eda976d78c..ff10701bbd 100644 --- a/aerospike_helpers/operations/operations.py +++ b/aerospike_helpers/operations/operations.py @@ -119,18 +119,18 @@ def increment(bin_name, amount): def touch(ttl: Optional[int] = None): """Create a touch operation dictionary. - Using ttl here is deprecated. It should be set in the record metadata for the operate method. + Using ttl here is deprecated. It should be set in the policy parameter for the operate method. Args: ttl (int): Deprecated. The ttl that should be set for the record. - This should be set in the metadata passed to the operate or + This should be set in the policy parameter passed to the operate or operate_ordered methods. Returns: A dictionary to be passed to operate or operate_ordered. """ op_dict = {"op": aerospike.OPERATOR_TOUCH} if ttl: - warnings.warn("TTL should be specified in the meta dictionary for operate", DeprecationWarning) + warnings.warn("TTL should be specified in the policy parameter for operate", DeprecationWarning) op_dict["val"] = ttl return op_dict From e52682d79a0ece6e7c7eb6651148134e43186fe5 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 5 Dec 2025 15:32:51 -0800 Subject: [PATCH 20/25] Use macro --- src/include/client.h | 4 ++++ src/main/client/operate.c | 8 ++------ src/main/client/put.c | 4 +--- src/main/client/remove.c | 4 +--- src/main/client/remove_bin.c | 4 +--- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/include/client.h b/src/include/client.h index 4ba9447916..f66860ffbf 100644 --- a/src/include/client.h +++ b/src/include/client.h @@ -25,6 +25,10 @@ #define CLUSTER_NPARTITIONS (4096) +#define DEPRECATE_META_PARAMETER_WARNING_MESSAGE \ + "meta parameter is deprecated and will be removed in the " \ + "next client major release" + /******************************************************************************* * Macros for UDF operations. ******************************************************************************/ diff --git a/src/main/client/operate.c b/src/main/client/operate.c index cd53d144d9..352957cce1 100644 --- a/src/main/client/operate.c +++ b/src/main/client/operate.c @@ -928,9 +928,7 @@ static PyObject *AerospikeClient_Operate_Invoke(AerospikeClient *self, if (py_meta) { PyErr_WarnEx(PyExc_DeprecationWarning, - "meta parameter is deprecated and will be removed in the " - "next client major release.", - 2); + DEPRECATE_META_PARAMETER_WARNING_MESSAGE, 2); } as_vector *unicodeStrVector = as_vector_create(sizeof(char *), 128); @@ -1273,9 +1271,7 @@ PyObject *AerospikeClient_OperateOrdered(AerospikeClient *self, PyObject *args, if (py_meta) { PyErr_WarnEx(PyExc_DeprecationWarning, - "meta parameter is deprecated and will be removed in the " - "next client major release.", - 2); + DEPRECATE_META_PARAMETER_WARNING_MESSAGE, 2); } CHECK_CONNECTED(&err); diff --git a/src/main/client/put.c b/src/main/client/put.c index 339d3df24e..9b139ae360 100644 --- a/src/main/client/put.c +++ b/src/main/client/put.c @@ -170,9 +170,7 @@ PyObject *AerospikeClient_Put(AerospikeClient *self, PyObject *args, if (py_meta) { PyErr_WarnEx(PyExc_DeprecationWarning, - "meta parameter is deprecated and will be removed in the " - "next client major release.", - 2); + DEPRECATE_META_PARAMETER_WARNING_MESSAGE, 2); } if (py_serializer_option) { diff --git a/src/main/client/remove.c b/src/main/client/remove.c index e55b2c5c11..1ead859625 100644 --- a/src/main/client/remove.c +++ b/src/main/client/remove.c @@ -172,9 +172,7 @@ PyObject *AerospikeClient_Remove(AerospikeClient *self, PyObject *args, if (py_meta) { PyErr_WarnEx(PyExc_DeprecationWarning, - "meta parameter is deprecated and will be removed in the " - "next client major release.", - 2); + DEPRECATE_META_PARAMETER_WARNING_MESSAGE, 2); } // Invoke Operation diff --git a/src/main/client/remove_bin.c b/src/main/client/remove_bin.c index 56faef8534..0c72bfbbf0 100644 --- a/src/main/client/remove_bin.c +++ b/src/main/client/remove_bin.c @@ -170,9 +170,7 @@ PyObject *AerospikeClient_RemoveBin(AerospikeClient *self, PyObject *args, if (py_meta) { PyErr_WarnEx(PyExc_DeprecationWarning, - "meta parameter is deprecated and will be removed in the " - "next client major release.", - 2); + DEPRECATE_META_PARAMETER_WARNING_MESSAGE, 2); } if (!self || !self->as) { From a88f237674627d360ed8395545904a9cb80cba59 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 5 Dec 2025 15:37:56 -0800 Subject: [PATCH 21/25] This test will not fail if an invalid key is passed --- test/new_tests/test_new_constructor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/new_tests/test_new_constructor.py b/test/new_tests/test_new_constructor.py index d9233c5b1e..43500b0f26 100644 --- a/test/new_tests/test_new_constructor.py +++ b/test/new_tests/test_new_constructor.py @@ -322,6 +322,8 @@ def test_config_level_misc_options(): # We just make sure that the above options are allowed as dict keys try: aerospike.client(config) + except e.ParamError as exc: + raise exc except: pass From 142ad28d2765675d717ad3af02afb2428ae5f8b2 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 5 Dec 2025 15:40:53 -0800 Subject: [PATCH 22/25] Rename to something better. --- ...est_new_constructor.py => test_client_config_level_options.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/new_tests/{test_new_constructor.py => test_client_config_level_options.py} (100%) diff --git a/test/new_tests/test_new_constructor.py b/test/new_tests/test_client_config_level_options.py similarity index 100% rename from test/new_tests/test_new_constructor.py rename to test/new_tests/test_client_config_level_options.py From e33a7eb6ea064a94e147606a327c6258644e5453 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 5 Dec 2025 16:14:40 -0800 Subject: [PATCH 23/25] socket_timeout isn't in docs --- test/new_tests/test_client_config_level_options.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/new_tests/test_client_config_level_options.py b/test/new_tests/test_client_config_level_options.py index 43500b0f26..9059b23e8d 100644 --- a/test/new_tests/test_client_config_level_options.py +++ b/test/new_tests/test_client_config_level_options.py @@ -280,7 +280,6 @@ def test_query_invalid_expected_duration(): # Some of these options may not be documented, but they are allowed in the code and customers may be using them def test_config_level_misc_options(): config = copy.deepcopy(gconfig) - config["policies"]["socket_timeout"] = 1 config["policies"]["total_timeout"] = 1 config["policies"]["max_retries"] = 1 config["policies"]["exists"] = aerospike.POLICY_EXISTS_CREATE From 04b65845c904ae26d060e2efd84415c378d81cca Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 5 Dec 2025 16:21:24 -0800 Subject: [PATCH 24/25] Add more test cases for checking that warning is raised for using meta parameter --- test/new_tests/test_get_put.py | 7 ++++++- test/new_tests/test_increment.py | 7 ++++++- test/new_tests/test_operate.py | 6 +++++- test/new_tests/test_operate_ordered.py | 6 +++++- test/new_tests/test_prepend.py | 6 +++++- test/new_tests/test_remove.py | 1 + 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/test/new_tests/test_get_put.py b/test/new_tests/test_get_put.py index 628078a5bd..74c000d538 100644 --- a/test/new_tests/test_get_put.py +++ b/test/new_tests/test_get_put.py @@ -14,6 +14,7 @@ import aerospike from aerospike import exception as e +import warnings @contextmanager @@ -262,7 +263,11 @@ def test_pos_put_with_policy_exists_create_or_replace(self): "gen": aerospike.POLICY_GEN_IGNORE, "key": aerospike.POLICY_KEY_SEND, } - assert 0 == self.as_connection.put(key, rec, meta, policy) + + with warnings.catch_warnings(record=True) as warning_list: + assert 0 == self.as_connection.put(key, rec, meta, policy) + assert len(warning_list) == 1 + assert warning_list[0].category == DeprecationWarning (key, meta, bins) = self.as_connection.get(key) assert rec == bins diff --git a/test/new_tests/test_increment.py b/test/new_tests/test_increment.py index 1f6e71acae..9ad084c827 100644 --- a/test/new_tests/test_increment.py +++ b/test/new_tests/test_increment.py @@ -7,6 +7,7 @@ from aerospike import exception as e import aerospike +import warnings class TestIncrement(object): @@ -127,7 +128,11 @@ def test_increment_with_policy_key_gen_EQ_ignore(self): } meta = {"gen": 10, "ttl": 1200} - self.as_connection.increment(key, "age", 5, meta, policy) + with warnings.catch_warnings(record=True) as warning_list: + self.as_connection.increment(key, "age", 5, meta, policy) + + assert len(warning_list) == 1 + assert warning_list[0].category == DeprecationWarning (key, meta, bins) = self.as_connection.get(key) diff --git a/test/new_tests/test_operate.py b/test/new_tests/test_operate.py index 3c5a9550b8..ce4406bd52 100644 --- a/test/new_tests/test_operate.py +++ b/test/new_tests/test_operate.py @@ -4,6 +4,7 @@ import aerospike from aerospike import exception as e +import warnings # OPERATIONS # aerospike.OPERATOR_WRITE @@ -297,7 +298,10 @@ def test_pos_operate_with_policy_gen_ignore(self, key, policy, meta, llist): Invoke operate() with gen ignore. """ - key, meta, bins = self.as_connection.operate(key, llist, meta, policy) + with warnings.catch_warnings(record=True) as warning_list: + key, meta, bins = self.as_connection.operate(key, llist, meta, policy) + assert len(warning_list) == 1 + assert warning_list[0].category == DeprecationWarning assert bins == {"name": "name1aa"} assert key == ( diff --git a/test/new_tests/test_operate_ordered.py b/test/new_tests/test_operate_ordered.py index 67a10299b0..f940965a0c 100644 --- a/test/new_tests/test_operate_ordered.py +++ b/test/new_tests/test_operate_ordered.py @@ -5,6 +5,7 @@ import aerospike from aerospike import exception as e from aerospike_helpers.operations import operations +import warnings class TestOperateOrdered(object): @@ -222,7 +223,10 @@ def test_pos_operate_ordered_policy_gen_ignore(self, key, policy, meta, llist): """ Invoke operate_ordered() with gen ignore. """ - key, meta, bins = self.as_connection.operate_ordered(key, llist, meta, policy) + with warnings.catch_warnings(record=True) as warning_list: + key, meta, bins = self.as_connection.operate_ordered(key, llist, meta, policy) + assert len(warning_list) == 1 + assert warning_list[0].category == DeprecationWarning assert bins == [("name", "name1aa")] diff --git a/test/new_tests/test_prepend.py b/test/new_tests/test_prepend.py index e6bfb08e9a..e5b67bd8e1 100644 --- a/test/new_tests/test_prepend.py +++ b/test/new_tests/test_prepend.py @@ -4,6 +4,7 @@ from .test_base_class import TestBaseClass import aerospike from aerospike import exception as e +import warnings class TestPrepend: @@ -101,7 +102,10 @@ def test_pos_prepend_with_policy_key_gen_EQ_ignore(self): } meta = {"gen": 10, "ttl": 1200} - self.as_connection.prepend(key, "name", "str", meta, policy) + with warnings.catch_warnings(record=True) as warning_list: + self.as_connection.prepend(key, "name", "str", meta, policy) + assert len(warning_list) == 1 + assert warning_list[0].category == DeprecationWarning (key, meta, bins) = self.as_connection.get(key) diff --git a/test/new_tests/test_remove.py b/test/new_tests/test_remove.py index c0ed09126e..55643433f1 100644 --- a/test/new_tests/test_remove.py +++ b/test/new_tests/test_remove.py @@ -6,6 +6,7 @@ from .test_base_class import TestBaseClass import aerospike from aerospike import exception as e +import warnings @pytest.mark.usefixtures("as_connection") From 08b3d90551608959d8c47140ca672619438169f3 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Sun, 7 Dec 2025 19:09:01 -0800 Subject: [PATCH 25/25] Just undo to be consistent --- doc/client.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/client.rst b/doc/client.rst index bb43862994..ffbdf132a6 100755 --- a/doc/client.rst +++ b/doc/client.rst @@ -104,7 +104,7 @@ Record Commands :param tuple key: a :ref:`aerospike_key_tuple` associated with the record. :param dict bins: contains bin name-value pairs of the record. - :param dict meta: Deprecated: record metadata to be set. see :ref:`metadata_dict`. + :param dict meta: record metadata to be set. see :ref:`metadata_dict`. :param dict policy: see :ref:`aerospike_write_policies`. :param serializer: override the serialization mode of the client \