couchbaselabs/TouchDB-iOS — pull request #204 by pegli (2012-12-27 01:08:25+00:00)
Title: bug fix: issue 203

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.