Error message if DS.RESTAdapter.find() sends invalid json parameter to its ajax success function #820

Closed
hlineholm opened this Issue Mar 19, 2013 · 2 comments

Comments

Projects
None yet
3 participants

I delivered:

{
    "booklet_source": [
        {
            "_id": "7b1a54440a0ac95c050f9d8e8318de29",
            "_rev": "3-be101a0ab85e2b6b9f0a3ef5b101980e",
            "area": "uppsala",
            "type": "booklet_source"
        }
    ]
}

as an response to the ajax request sent by DS.RESTAdapter.find() when I should have delivered:

{
    "booklet_source": {
        "_id": "7b1a54440a0ac95c050f9d8e8318de29",
        "_rev": "3-be101a0ab85e2b6b9f0a3ef5b101980e",
        "area": "uppsala",
        "type": "booklet_source"
    }
}

This caused the success function of the same request to send this.didFindRecord(store, type, json, id) with json[booklet_source] as an array instead of an object. Thus resulting in an overwrite of the corresponding model with its attributes all set to "null". This because the process of loading data from the json object to the newly created record, requires this.clientIdToData[index], or cidToData[index], to deliver an object, not an array.

I would have saved one day of searching for my bug if I had got an error message saying that the DS.RESTAdapter.find() expects an object not an array.

Member

pangratz commented Mar 25, 2013

@hholmgren it looks like you are using CouchDB, so I shamelessly leave a link to https://github.com/pangratz/ember-couchdb-adapter 🏃

Owner

wagenet commented Aug 10, 2013

We definitely should add some more assertions.

wycats closed this in 9a9b5ec Sep 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment