We have a situation where we have a course that has an enrolment (which is allowed to be null).

I quickly fixed this in my own version with:

```javascript
    var key = this.keyForAttribute(attr);
    var embeddedRecord = record.get(attr);
    if (embeddedRecord) {
      json[key] = embeddedRecord.serialize();
      var id = embeddedRecord.get('id');
      if (id) {
        json[key].id = id;
      } else {
        json[key][clientIdKey] = this.createClientId(embeddedRecord);
      }

      var parentKey = this.keyForAttribute(relationship.parentType.typeKey);
      if (parentKey) {
        removeId(parentKey, json[key]);
      }
      delete json[key][parentKey];
    }
```

As for a test. I can write one for you tomorrow if you don't get a chance