CDM icon indicating copy to clipboard operation
CDM copied to clipboard

Fix reading the primary key property of resolved entities

Open trickpatty opened this issue 6 months ago • 0 comments

This change fixes an issue where, when reading the PrimaryKey property of an entity which was resolved from an abstract manifest (with the identifiedBy purpose on an attribute), the value cannot be retrieved.

When FetchTraitReferenceArgumentValue returns the value of the argument for the resolved is.identifiedBy trait, it returns either a string or a CdmAttributeReference. However, the subsequent process was looking to cast to a CdmTypeAttributeDefinition, which is not a compatible type. Since the only thing the code needs from that object is the name, it is safe to cast to the CdmObject instead and call the underlying FetchObjectDefinitionName() method.

This change makes the cast to CdmObject and returns the value successfully.

A unit test which addresses this situation is also included in the changes.

trickpatty avatar Aug 08 '24 20:08 trickpatty