Fixes #816 UnitOfWork::doDetach wasn't clearing documentUpserts

Fixes #816