Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/reduct/bucket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
27 changes: 27 additions & 0 deletions tests/reduct/entry_api_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>{"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();

Expand Down
7 changes: 0 additions & 7 deletions tests/reduct/replication_api_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading