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
For each entity in a model, cds-typer generates a singular and a plural entity.
As CDS assumes entities to be described in plural form, the entity's name in CSN is assumed to be the plural form, and a singular form is automatically derived.
As this mechanism is very prone to errors, users can specify a custom name for either singular or plural (or both) using the @singular and @plural annotations.
These annotations are meant only for the entity they are attached to. cds-typer will make sure these annotation stay at their respective root entity. If @singular and @plural were propagated, they could spread to unrelated entities through aspects and cause naming collisions:
But in some cases, it may actually be desirable to retain these annotations. For example, when projecting on an entity without renaming it:
@singular:'Scroll'entityBook {}
serviceBookshop {
entityBookasprojectiononBook {} // Bookshop.Book should actually become Bookshop.Scroll, for convenience
}
Solutions
Repeat @singular/ @plural
This is the current solution. If a users wants to have custom singular/ plural for projections, they have to repeat the annotation on the projection.
Another Annotation
Have another annotation that expresses that @singular/ @plural on this entity should be propagated:
Have a setting to force cds-typer to always or never propagate inflection annotations:
cds-typer --propagateInflection true"*"
Related Issues
The current behaviour of not propagating @singular/ @plural, whereas all other annotations are propagated, caused confusion at least once in the past #425
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
For each entity in a model, cds-typer generates a singular and a plural entity.
As CDS assumes entities to be described in plural form, the entity's name in CSN is assumed to be the plural form, and a singular form is automatically derived.
As this mechanism is very prone to errors, users can specify a custom name for either singular or plural (or both) using the
@singularand@pluralannotations.These annotations are meant only for the entity they are attached to. cds-typer will make sure these annotation stay at their respective root entity. If
@singularand@pluralwere propagated, they could spread to unrelated entities through aspects and cause naming collisions:would result in
But in some cases, it may actually be desirable to retain these annotations. For example, when projecting on an entity without renaming it:
Solutions
Repeat
@singular/@pluralThis is the current solution. If a users wants to have custom singular/ plural for projections, they have to repeat the annotation on the projection.
Another Annotation
Have another annotation that expresses that
@singular/@pluralon this entity should be propagated:Meta Annotation
Introduce an annotation for the two inflection annotations:
This would require involvement with the compiler, as this kind of meta annotations is not supported as of today.
Object-Valued
@singular/@pluralIn addition to string values, allow object values containing this type of meta information:
Globally Configure cds-typer
Have a setting to force cds-typer to always or never propagate inflection annotations:
Related Issues
The current behaviour of not propagating
@singular/@plural, whereas all other annotations are propagated, caused confusion at least once in the past#425
Beta Was this translation helpful? Give feedback.
All reactions