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

Comments

Projects
None yet
2 participants
@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

nicolaiarocci added a commit that referenced this issue Mar 30, 2019

@nicolaiarocci nicolaiarocci added this to the 0.8.2 milestone Mar 30, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.