You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.
When I work with a document that is deleted in the background by another process, I expect to get a KeyError either when I access it as a dictionary, or when I do fetch. I get a 404 HTTPError.
What's worse, if I do id in DB, it still says True
1. Steps to reproduce and the simplest code sample possible to demonstrate the issue
try:
ticket = mydb['testdocument']
ticket.fetch()
except KeyError:
print("Document was deleted")
# I delete the document directly in the database
try:
'testdocument' in mydb # returns True
ticket = mydb['testdocument'] # executes correctly
ticket.fetch() # raises the HttpError
except KeyError:
print("Nope")
2. What you expected to happen
I expected a KeyError raised at least when I did fetch. I expected 'testdocument' in mydb to return False after I deleted the document (and before doing fetch)
3. What actually happened
HttpError, 404 status code
Environment details
Version(s) that are affected by this issue.
2.14.0
Python version
3.8.2
Linux version
Ubuntu 20.04
I have quite a few KeyErrors that I expect raised if the doc doesn't exist, regardless of whether I've fetched the document before or not. I'd hate to have to change all of those, please tell me that I'm doing something wrong.
The text was updated successfully, but these errors were encountered:
Calling fetch explicitly asks the remote server for the document - so the HttpError 404 is the expected response as the document is now deleted on the server.
are correct even after the remote deletion occurs because they are operating on the local dict which still contains a previous revision of the document (i.e. the local cache knows nothing of the remote update/deletion until fetch is called).
It appears that after the fetch [of the deleted remote revision] is called the local cache still retains the undeleted revision. Personally I think that behaviour is not correct; more likely it should follow similar behaviour to the delete function. However, given the deprecation timeline for this library I don't think we'll be making changes to that behaviour at this stage.
If you find the local cache behaviour awkward it is worth noting that our replacement library ibmcloudant/cloudant-python-sdk does not have it.
Bug Description
When I work with a document that is deleted in the background by another process, I expect to get a KeyError either when I access it as a dictionary, or when I do fetch. I get a 404 HTTPError.
What's worse, if I do
id in DB
, it still says True1. Steps to reproduce and the simplest code sample possible to demonstrate the issue
2. What you expected to happen
I expected a KeyError raised at least when I did fetch. I expected
'testdocument' in mydb
to return False after I deleted the document (and before doing fetch)3. What actually happened
HttpError, 404 status code
Environment details
I have quite a few KeyErrors that I expect raised if the doc doesn't exist, regardless of whether I've fetched the document before or not. I'd hate to have to change all of those, please tell me that I'm doing something wrong.
The text was updated successfully, but these errors were encountered: