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() will create new items #51

Closed
jkav77 opened this issue Dec 21, 2016 · 3 comments
Closed

.update() will create new items #51

jkav77 opened this issue Dec 21, 2016 · 3 comments

Comments

@jkav77
Copy link
Collaborator

jkav77 commented Dec 21, 2016

This was brought up in #39, but is separate from the main issue there which is schema enforcement. Basically, you can create a new item in DynamoDB with an update call. The expected behavior should be to fail and only allow creating new items with a call to .create().

@deedw
Copy link

deedw commented Dec 23, 2016

See comments against pull request #50. I believe existing functionality is as expected for DynamoDb and changes to this would break existing code.

@jkav77
Copy link
Collaborator Author

jkav77 commented Dec 24, 2016

@deedw Given the underlying behavior of DynamoDB.updateItem(), I agree that the current behavior is as expected. In my projects, attempting to update a non-existent item has always represented an error case I would want to know about. This issue made sense to me in that context.

Having looked through the code now, it appears that you can do this easily with the param object like { expected: { id: { Exists: true } } }. I don't see this in the documentation, so I will change the PR to add this to the docs after I finish testing to make sure this actually works as I think it does.

@jkav77
Copy link
Collaborator Author

jkav77 commented Dec 24, 2016

I updated the documentation in #53. This provides an easy way to modify the behavior of .update() to fail for items that don't exist. In fact, this was an undocumented feature already in the code. I added two tests to check the behavior works and described the parameter in the README.md.

@jkav77 jkav77 closed this as completed Dec 24, 2016
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

2 participants