Avoid error when rebuilding database

This commit is contained in:
Martchus 2024-03-09 12:11:52 +01:00
parent 3a2160ee67
commit 71b613bc7c
2 changed files with 10 additions and 1 deletions

View File

@ -157,7 +157,8 @@ template <class Class, typename Type, typename Parent> struct LMDB_SAFE_EXPORT L
void del(MDBRWTransaction &txn, const Class &t, IDType id)
{
if (const auto rc = txn->del(d_idx, keyConv(d_parent->getMember(t)), id)) {
const auto rc = txn->del(d_idx, keyConv(d_parent->getMember(t)), id);
if (rc && rc != MDB_NOTFOUND) {
throw LMDBError("Error deleting from index: ", rc);
}
}

View File

@ -104,5 +104,13 @@ TEST_CASE("Basic typed tests", "[basictyped]")
REQUIRE(out.lastName == "testperson");
REQUIRE(out.enrolled == m.enrolled);
// rebuild the database
txn.rebuild([] (IDType, Member *member) {
return member->firstName != "bertus";
});
REQUIRE(txn.size() == 2);
REQUIRE(txn.size<0>() == txn.size());
REQUIRE(!txn.get<0>("bertus", out));
txn.abort();
}