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
I am working on an SAP CAP application using TypeScript, and I’ve encountered an issue where cds-typer does not generate the singular form of an entity correctly in the index.ts and index.js files. This causes the singular entity reference to be undefined in the service handler.
Expected Behavior
The singular form of the entity (ParentEntity) should be properly generated and accessible in the service handler as this.cds.CustomParentEntity.
Impact:
Without a properly generated singular entity, I cannot reference it directly in the service handler, requiring workarounds such as manually using @singular and @plural on service level.
Steps To Reproduce
Define an entity in the db folder with @singular and @plural annotations, including a composition.
Create a service projection on the entity.
Attempt to reference the singular entity in the service handler.
Scenario:
Entity Definition in the db Folder:
I have a projection entity defined with @singular and @plural annotations. The entity includes a composition that references another entity. Here's an example:
//CDS code
@plural : 'CustomParentEntities'
@singular: 'CustomParentEntity'
entity ParentEntities as projection on BaseParent {
*,
relatedChild : Composition of one ChildEntities on
relatedChild.parentID = $self.ID
};
Service Definition:
In my service file, I have another projection on this entity: entity ProjectedEntities as projection on ParentEntities;
Service Handler:
Inside the service handler, I attempt to reference the singular entity (CustomParentEntity) for an operation:
The CustomParentEntity is not properly generated as a singular class.
Suggested Fix:
Ensure that the singular entity is correctly generated in both index.ts and index.js files, so it can be directly referenced in TypeScript and JavaScript code, like:
this.cds.CustomParentEntity; // Should not be undefined
can you please extend your sample code to be a minimal reproducible example, i.e. include all missing entities, like BaseParent, etc. and clearly label where each file is supposed to be located? Thanks!
Is there an existing issue for this?
Nature of Your Project
TypeScript
Current Behavior
I am working on an SAP CAP application using TypeScript, and I’ve encountered an issue where
cds-typer
does not generate the singular form of an entity correctly in theindex.ts
andindex.js
files. This causes the singular entity reference to be undefined in the service handler.Expected Behavior
The singular form of the entity (
ParentEntity
) should be properly generated and accessible in the service handler asthis.cds.CustomParentEntity
.Impact:
Without a properly generated singular entity, I cannot reference it directly in the service handler, requiring workarounds such as manually using
@singular
and@plural
on service level.Steps To Reproduce
db
folder with@singular
and@plural
annotations, including a composition.Scenario:
I have a projection entity defined with
@singular
and@plural
annotations. The entity includes a composition that references another entity. Here's an example:Service Definition:
In my service file, I have another projection on this entity:
entity ProjectedEntities as projection on ParentEntities;
Service Handler:
Inside the service handler, I attempt to reference the singular entity (CustomParentEntity) for an operation:
Problem
In this scenario,
this.cds.CustomParentEntity
isundefined
. After inspecting the generated TypeScript and JavaScript files, I observed the following:Generated
index.ts
:Generated
index.js
:The
CustomParentEntity
is not properly generated as a singular class.Suggested Fix:
Ensure that the singular entity is correctly generated in both
index.ts
andindex.js
files, so it can be directly referenced in TypeScript and JavaScript code, like:this.cds.CustomParentEntity; // Should not be undefined
Environment
Repository Containing a Minimal Reproducible Example
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: