The documentation seems to indicate that the returned type should be a DS.Model Object, and I believe this is the way it has worked previously, but now when testing with Ember.Data 2.5.2 type is a string with the model name. Is this a bug or is the documentation incorrect? parentType seems to be a DS.Model just like the documentation states.
http://emberjs.com/api/data/classes/DS.Model.html#method_eachRelationship
http://emberjs.com/api/data/classes/DS.Model.html#property_relationshipsByName
Ember.get(this.get('store').modelFor('customer'), 'relationshipsByName')
Map {_keys: OrderedSet, _values: EmptyObject, size: 1}
_keys: OrderedSet
_values: EmptyObject
st322: Object
isRelationship: true
key: "orders"
kind: "hasMany"
options: Object
parentType: (unknown mixin)
type: "order"
I was able to track down the change to this commit: https://github.com/emberjs/data/commit/405f9c503c704ecb5dae569f54529b46e5e53282
Seems like it returned the type in some cases and the string in others previously. But I guess now it should always return a string?
- if (typeof modelName === 'string') {
- if (meta.kind === 'hasMany') {
- modelName = singularize(modelName);
- }
- typeClass = store.modelFor(modelName);
- } else {
- typeClass = meta.type;
- }
-
- return typeClass;
+ return singularize(normalizeModelName(modelName));
Are they intended to always return an string? In that case I guess the documentation should be updated.
Hi @mkrisa,
Yep, I think this was an intentional breaking change. We wanted to make class instances safer to be concurrent in the fastboot environment. Would you mind opening a PR?
Thanks for the info, I will open a PR with proposed documentation changes.
Most helpful comment
Thanks for the info, I will open a PR with proposed documentation changes.