Kittyfisto/IsabelDb

IDatabase.CreateXYZ doesn't behave as expected when used inside transactions

Closed this issue · 0 comments

Given the following code:

using (var transaction = db.BeginTransaction())
{
   db.CreateBag<string>("Stuff");
   //transaction.Commit();
}

I would expected db.Collections to be empty. Furthermore, I would expect that the database truly doesn't contain that collection (i.e. closing and opening the database will still show that no such collection exists). Currently, only the latter is the case, but the list of collections still mentions that collection whose creation should've been rolled back.

A simple fix would be to have the ITransaction.Dispose() method notify the IDatabase implementation that a rollback occured which would then remove those collections affected by the rollback.

The very same thing must also occur for collection removals, i.e.:

using (var transaction = db.BeginTransaction())
{
   db.Remove("Stuff");
   //transaction.Commit();
}

may not have removed the collection after all.