Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#update_doc when the doc does not exist is broken #127

Open
blairio opened this issue Oct 20, 2016 · 0 comments
Open

#update_doc when the doc does not exist is broken #127

blairio opened this issue Oct 20, 2016 · 0 comments

Comments

@blairio
Copy link

blairio commented Oct 20, 2016

Currently calling doc.update_doc(<id>) with an ID that does not exist throws the wrong exception.

NoMethodError:
       undefined method `[]=' for nil:NilClass
     # ./lib/couchrest/database.rb:254:in `update_doc'

Previous versions of CouchRest threw this exception:

RestClient::ResourceNotFound:` 404 Resource Not Found: {"error":"not_found","reason":"missing"}

Now that #get returns nil, it just carries on and passes nil to the block and then nil to save_doc.

I am not sure if the best solution is to raise an exception such as something like CouchRest:NotFound or pass in a new hash instantiated with the id ie {'_id' => <id>} or something else.

I sort of like instantiating, which I think would be sort of like an upsert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant