You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The only way to configure around this requires knowing about ember-inflector and ensuring that you get the inflector rules in place prior to relationship instantiation. Asking somebody to know about initializers and ember-inflector when they're just starting to configure Ember Data for the first time is another papercut that continues the "Ember Data is hard" trope.
Everything else about Ember Data is customizable given normalizeModelNameexcept for this one singularization behavior. Nothing internal to Ember Data requires singularization, nothing about the hasMany signature implies that we should allow users to pluralize the model name.
The explanation I can come up with for this feature is that it reads nicer in English in the model definition. But having N ways to accomplish a task is not a good API:
// No cheating, tell me which model this uses:hasMany('people')// Here's a hint, this one uses the same model:hasMany('persons')// And so does this one:hasMany('person')// All of them do the same thing, but in only one case is it// crystal clear where the backing files are.
Automatic singularization of hasMany should be deprecated. It's a mechanical change, so it's easy for users to do. And we already have a place where it's super-easy to insert a deprecation.
The text was updated successfully, but these errors were encountered:
Nothing internal to Ember Data requires singularization, nothing about the hasMany signature implies that we should allow users to pluralize the model name.
This isn't strictly true. We did to work recently to begin attempting to allow this, but there are still pitfalls everywhere and we assert that you've normalized at most entry points for this reason.
runspired
changed the title
hasMany forces you through singularize
hasMany might be the last remaining place that enforces singularizeJun 3, 2018
runspired
changed the title
hasMany might be the last remaining place that enforces singularize
Don't require singularized type: (hasMany might be the last remaining place)
Jun 3, 2018
The only way to configure around this requires knowing about ember-inflector and ensuring that you get the inflector rules in place prior to relationship instantiation. Asking somebody to know about initializers and ember-inflector when they're just starting to configure Ember Data for the first time is another papercut that continues the "Ember Data is hard" trope.
Offending code:
https://github.com/emberjs/data/blob/e3a24f6/addon/-private/system/relationship-meta.js#L10
Everything else about Ember Data is customizable given
normalizeModelName
except for this one singularization behavior. Nothing internal to Ember Data requires singularization, nothing about thehasMany
signature implies that we should allow users to pluralize the model name.The explanation I can come up with for this feature is that it reads nicer in English in the model definition. But having N ways to accomplish a task is not a good API:
We already don't recommend this; the current Ember Data docs use the actual model name when defining a
hasMany
relationship:https://guides.emberjs.com/release/models/relationships/
So let's fix this. Proposal:
hasMany
should be deprecated. It's a mechanical change, so it's easy for users to do. And we already have a place where it's super-easy to insert a deprecation.The text was updated successfully, but these errors were encountered: