bug fix: issue 203 #204

wants to merge 2 commits into


None yet

2 participants

pegli commented Dec 27, 2012

Here's the fix for this issue. The only part you might want to look at is the call to [self.database clearDocumentCache] in purgeDocument:. I feel like the purged document should be removed from the cache so it isn't returned again if cachedDocumentWithID: is called. Clearing the whole document cache is a bit drastic, but removing a single document from the cache would require a new method on TDDatabase.

Note that calling purgeDocument followed by documentWithID will result in a new, empty document with the same ID as the purged document. This is a bit confusing ("hey, I just purged document F45E1789-5754-41AC-8FF6-444207B919DB -- why is it coming back?") but this behavior is as designed for documentWithID, which will return a new doc if the provided doc ID doesn't exist. This is also the reason the unit test uses cachedDocumentWithID: when attempting to re-select the purged doc.

snej commented on 8f3bc41 Dec 31, 2012

Clearing the document cache would be bad, as it would affect other TDDocuments and lead to multiple TDDocument instances for the same document ID. Instead we need to just remove this document ID from the cache.


Agreed. I will add a new method to TDDatabase which removes a specific document from the cache, update purgeDocument, and resubmit the pull request.

@pegli pegli closed this Jan 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment