lanto03 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

Enhanced document deletion handling #155

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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

Original issue reported on code.google.com by daevaorn on 30 Sep 2010 at 5:30

Attachments:

GoogleCodeExporter commented 8 years ago
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.

Original comment by djc.ochtman on 22 Dec 2010 at 11:57

GoogleCodeExporter commented 8 years ago
Upload a better path with test

Original comment by daevaorn on 13 Mar 2011 at 11:45

Attachments:

GoogleCodeExporter commented 8 years ago
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:
>>>   ...

Original comment by kxepal on 14 Mar 2011 at 9:35

GoogleCodeExporter commented 8 years ago
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`.

Original comment by daevaorn on 14 Mar 2011 at 9:43

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Upload a better patch with `mapping.Document` handling of the deleted documents 
that come from views.

Original comment by daevaorn on 14 Mar 2011 at 9:59

Attachments:

GoogleCodeExporter commented 8 years ago
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.

Original comment by kxepal on 15 Mar 2011 at 2:38

GoogleCodeExporter commented 8 years ago
This issue has been migrated to GitHub. Please continue discussion here:

https://github.com/djc/couchdb-python/issues/155

Original comment by djc.ochtman on 15 Jul 2014 at 7:19