SAP / open-ux-odata

Enable community collaboration to jointly promote and facilitate best in class framework and tooling capabilities when working with OData services.
Apache License 2.0
51 stars 10 forks source link

BUG - Wrong __metadata id/uri when using a single key with Edm.Guid #666

Closed sb-aigh closed 1 year ago

sb-aigh commented 1 year ago

Description

Assuming one has defined a V2 entity with a single key of type Edm.Guid, like....

<EntityType Name="MyEntity">
    <Key>
        <PropertyRef Name="ID"/>
    </Key>
    <Property Name="ID" Type="Edm.Guid" Nullable="false"/>
    ...
</EntityType>

The function addV2Metadata in dataAccess.ts composes an uri like /MyEntities(3cd0813b921744539da05c34d72ec7fa) which is not correct. I think, the metadata uri should have the format /MyEntities(guid'3cd0813b921744539da05c34d72ec7fa') in that case.

Expected results

The __metadata id/uri should have the correct path with ID having the right format like /MyEntities(guid'3cd0813b921744539da05c34d72ec7fa').

nlunets commented 1 year ago

This is fixed in version @sap-ux/ui5-middleware-fe-mockserver@2.1.114

sb-aigh commented 1 year ago

Unfortunately, the patch does not fix all scenarios. If the entity has just one key using Edm.Guid then still the returned metadata is wrong. You need to add the same logic here for branch if (Object.keys(currentKeys).length === 1) { probably?!

jonaszuberbuehler commented 1 year ago

This doesn't only apply to Edm.Guid, the single quotes are also missing for Edm.String as an example.

nlunets commented 1 year ago

Most likely fixed by [@sap-ux/ui5-middleware-fe-mockserver@2.1.115]