From 6673dcfe87782e37544ff270a5bad6fbe0e4b16f Mon Sep 17 00:00:00 2001 From: Alexey Timin Date: Mon, 9 Mar 2026 18:20:38 +0100 Subject: [PATCH 1/3] fix numeric attachment key deletion --- src/reduct/bucket.cc | 2 +- tests/reduct/entry_api_test.cc | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/reduct/bucket.cc b/src/reduct/bucket.cc index 793c2da..149d7c4 100644 --- a/src/reduct/bucket.cc +++ b/src/reduct/bucket.cc @@ -253,7 +253,7 @@ class Bucket : public IBucket { if (!attachment_keys.empty()) { nlohmann::json when; when["$in"] = nlohmann::json::array(); - when["$in"].push_back("&key"); + when["$in"].push_back({{"&key", {{"$cast", "string"}}}}); for (const auto& key : attachment_keys) { when["$in"].push_back(key); } diff --git a/tests/reduct/entry_api_test.cc b/tests/reduct/entry_api_test.cc index e3acc94..680d903 100644 --- a/tests/reduct/entry_api_test.cc +++ b/tests/reduct/entry_api_test.cc @@ -755,6 +755,33 @@ TEST_CASE("reduct::IBucket should remove all entry attachments", "[entry_api][1_ REQUIRE(stored.empty()); } +TEST_CASE("reduct::IBucket should remove entry attachments with numeric keys", "[entry_api][1_19]") { + Fixture ctx; + auto [bucket, _] = ctx.client->CreateBucket(kBucketName); + REQUIRE(bucket); + + IBucket::AttachmentMap attachments{ + {"1", R"({"enabled":true,"values":[1,2,3]})"}, + {"2.5", R"({"name":"test"})"}, + }; + + REQUIRE(bucket->WriteAttachments("entry-1", attachments) == Error::kOk); + + auto [stored_before, err_before] = bucket->ReadAttachments("entry-1"); + REQUIRE(err_before == Error::kOk); + REQUIRE(stored_before.size() == 2); + REQUIRE(stored_before.contains("1")); + REQUIRE(stored_before.contains("2.5")); + REQUIRE(nlohmann::json::parse(stored_before.at("1")) == nlohmann::json::parse(attachments.at("1"))); + REQUIRE(nlohmann::json::parse(stored_before.at("2.5")) == nlohmann::json::parse(attachments.at("2.5"))); + + REQUIRE(bucket->RemoveAttachments("entry-1", std::set{"1", "2.5"}) == Error::kOk); + + auto [stored_after, err_after] = bucket->ReadAttachments("entry-1"); + REQUIRE(err_after == Error::kOk); + REQUIRE(stored_after.empty()); +} + TEST_CASE("Batch should slice data", "[batch]") { auto batch = IBucket::Batch(); From 64afb3431ed0ab64a9ebcb7f51847b9d1d407bb1 Mon Sep 17 00:00:00 2001 From: Alexey Timin Date: Mon, 9 Mar 2026 18:21:35 +0100 Subject: [PATCH 2/3] Update changelog for PR #113 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05d1263..c519bab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add entry attachments API (`WriteAttachments`, `ReadAttachments`, `RemoveAttachments`) for ReductStore API v1.19, [PR-112](https://github.com/reductstore/reduct-cpp/pull/112) +### Fixed + +- Fix removing attachments with numeric keys, [PR-113](https://github.com/reductstore/reduct-cpp/pull/113) + ## 1.18.0 - 2026-02-04 ### Added From aa7a690b1c111a7022b97f07dec36a9972fa44f7 Mon Sep 17 00:00:00 2001 From: Alexey Timin Date: Mon, 9 Mar 2026 20:10:52 +0100 Subject: [PATCH 3/3] remove flaky assertion --- tests/reduct/replication_api_test.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/reduct/replication_api_test.cc b/tests/reduct/replication_api_test.cc index a3b3034..06a24c3 100644 --- a/tests/reduct/replication_api_test.cc +++ b/tests/reduct/replication_api_test.cc @@ -89,13 +89,6 @@ TEST_CASE("reduct::Client should set replication mode", "[replication_api][1_18] auto [replication, err_2] = ctx.client->GetReplication("test_replication"); REQUIRE(err_2 == Error::kOk); - REQUIRE(replication.info == IClient::ReplicationInfo{ - .name = "test_replication", - .mode = IClient::ReplicationMode::kPaused, - .is_active = true, - .is_provisioned = false, - .pending_records = 0, - }); REQUIRE(replication.settings.mode == IClient::ReplicationMode::kPaused); REQUIRE(replication.settings.entries == settings.entries);