couchdb-python
couchdb-python copied to clipboard
Enhanced document deletion handling
From daevaorn on September 30, 2010 19:30:29
After the document deletion CouchDB returns response with updated revision. It will be very useful to store new revision in the document object.
Patch attached
Attachment: enhanced_delete.diff
Original issue: http://code.google.com/p/couchdb-python/issues/detail?id=155
From djc.ochtman on December 22, 2010 03:57:42
I don't know about this.
First off, the first hunk in the patch doesn't really help, I think (and it looks like it's completely untested; there's a reference to "doc" there that doesn't make sense).
For the delete() method, IMO just updating the _rev doesn't really make sense. If anything, we should modify the doc so that it only has _id, _rev and _deleted=True, to correctly represent the state of the doc in the database at that point.
Labels: -Type-Defect -Priority-Medium Type-Enhancement Priority-Low
From daevaorn on March 13, 2011 16:45:28
Upload a better path with test
Attachment: enhanced-delete.diff
From kxepal on March 14, 2011 14:35:13
Actually, Document will be never False because it's dict like and always filled, so may be using nonzero (bool) method will be more pythonic instead of deleted property?
if doc: ...
if not doc.deleted: ...
From daevaorn on March 14, 2011 14:43:27
I don't think so. Only empty dict ({}) is False. Deleted document isn't empty. It has some special state with additional attribute but not empty.
Just now I try to make one more patch for this ticket with more specific deletion handling especially in couchdb.mapping.Document
.
From daevaorn on March 14, 2011 14:59:16
Upload a better patch with mapping.Document
handling of the deleted documents that come from views.
Attachment: enhanced-delete.diff
From kxepal on March 14, 2011 19:38:36
Empty dict is False, yes, but this is Document object which must have _id and _rev keys if it exists. Document is high-level dict so, why not to have it high-level boolean conversion logic: return False if it deleter or no more existed and True otherwise? However, even if it will be empty (as dict), id and rev properties will generate KeyError exception and you'll still unable to print it.