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

Insertion failure when replacing a same document containing dbref #1216

Closed
smeng9 opened this issue Dec 7, 2018 · 0 comments
Closed

Insertion failure when replacing a same document containing dbref #1216

smeng9 opened this issue Dec 7, 2018 · 0 comments
Milestone

Comments

@smeng9
Copy link
Contributor

smeng9 commented Dec 7, 2018

Expected Behavior

The expected behavior when replacing a document with the same document requested, PyEve should always accept the document.

For example:

  1. modify the "works" definition in https://github.com/pyeve/eve-demo/blob/master/settings.py
    change the work owner's type from objectid to dbref.
  2. manually modify the test database with appropriate dbref data structure.
  3. make a request to the work document endpoint
    it will return
    {"_created": "Fri, 07 Dec 2018 19:07:07 GMT", "_id": "5c0ac4db3cad1f378bc436fe", "_links": {"collection": {"href": "works", "title": "works"}, "parent": {"href": "/", "title": "home"}, "self": {"href": "works/5c0ac4db3cad1f378bc436fe", "title": "Work"}}, "_updated": "Fri, 07 Dec 2018 19:18:33 GMT", "description": "Description #0", "id": "5c0ac4db3cad1f378bc436fe", "owner": {"$id": "5c0ac4db3cad1f378bc436fd", "$ref": "people"}, "title": "Book Title #0"}
    the owner now has two keys: $id and $ref
  4. make a put request to replace the original document endpoint, it should return with no error.

In short, executing
curl http://localhost:5000/works/5c0ac4db3cad1f378bc436fe -o curl.txt
then
curl -X PUT -d @curl.txt --header "Content-Type: application/json" http://localhost:5000/works/5c0ac4db3cad1f378bc436fe
should produce no error

Actual Behavior

the second request produced the following 422 error
{"_issues": {"owner": "must be of dbref type"}, "_status": "ERR"}

However, if I change owner from $ref to $col in the txt file, it will be able to replace the original document.
Seems the dbref fields are not defined consistently, and will cause confusion when actually using it.

Environment

  • Python version: 3.7.1
  • Eve version: 0.8.1
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