Skip to content

Insertion failure when replacing a same document containing dbref #1216

@smeng9

Description

@smeng9

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions