Avoid error when rebuilding database
This commit is contained in:
parent
3a2160ee67
commit
71b613bc7c
|
@ -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)
|
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);
|
throw LMDBError("Error deleting from index: ", rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,5 +104,13 @@ TEST_CASE("Basic typed tests", "[basictyped]")
|
||||||
REQUIRE(out.lastName == "testperson");
|
REQUIRE(out.lastName == "testperson");
|
||||||
REQUIRE(out.enrolled == m.enrolled);
|
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();
|
txn.abort();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue