Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Embedded one-to-one relationships represented as `null` trips up ember #593

sandstrom opened this Issue · 2 comments

2 participants


Embedded one-to-one relationships represented as null, instead of undefined (or omitted from the json payload) trips up ember.

This can (and probably should) be solved by the server-side serializer, but afaik the default for e.g. Active Model Serializers is to represent these as null.

Would it make sense for ember to handle null and undefined the same in this case (that would also solve the problem), or is there some drawback to that? For regular model fields the distinction between null and undefined can be important, but for embedded records I don't see a case where that should matter, though I may have overlooked something.

I hope this is clear enough, let me know if I should elaborate.

App.Mother = DS.Model.extend({
  name: attr('string')
  child: DS.belongsTo("App.Child")

App.Child = DS.Model.extend({
  voter: attr('string')
  mother: DS.belongsTo("App.Child")
});"App.Mother", {
  child: { embedded: 'always' }

// will instantiate a child on the mother, but as soon as it's accessed an error is thrown
    "id": 1,
    "name": "mother",
    "child": null
// works just fine
    "id": 1,
    "name": "mother"

Try #564


@ppcano I worked around it by using undefined instead of null, but thanks a lot for pointing me to the PR, I hadn't seen that.

Solved by #564, closing this issue.

@sandstrom sandstrom closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.