histrio/py-couchdb

delete_attachment don't delete the attachment

dedalus2000 opened this issue · 2 comments

The delete_attachment function deletes the file in the database, but does not delete it from the the document instance

In fact I can see in the source client.py#420:
..
if r.status_code < 206:
_doc['_rev'] = d['rev']
return _doc
..

So only the _rev attribute is updated, but the file informations will remain in the _doc['_attachment'] object

sorry for the tabs-alignment but my solution should be simple to understand

diff new_client.py old_client.py
421,427d420
< try:
< # we are under try/except as far we can delete nonexistent attachments
< del _doc['_attachments'][filename]
< if not _doc['_attachments']:
< del _doc['_attachments']
< except:
< pass

Thanks for you explanation! I fix it this afternoon. ;)