Uploaded image for project: 'OASIS Open Data Protocol (OData) TC'
  1. OASIS Open Data Protocol (OData) TC
  2. ODATA-1603

It is not clear if the entities in a collection returned by a function always have an entity-id

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: V4.01_OS
    • Fix Version/s: V4.01_ERRATA01
    • Component/s: Protocol
    • Labels:
      None
    • Proposal:
      Hide

      <See discussion below.>

      I believe that the standard should be updated to include two situations:

      1. A function returns a collection of entities that have keys and have no other container - In this case, it is not clear to me how the canonical URL should be generated for the entities in the returned collection. The standard may call this out somewhere, but I am not able to find it.
        1. Extend section https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_OperationResult to include function results - could be similar to containment case, including the parameter values in the canonical URL
      1. A function returns a collection of entities that do not have keys - In this case, I believe that these entities should be considered [transient entities](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_TransientEntities) and that the portion of the standard that talks about entity-ids should call out that transient entities do not have an entity-id.
      Show
      <See discussion below.> I believe that the standard should be updated to include two situations: A function returns a collection of entities that have keys and have no other container - In this case, it is not clear to me how the canonical URL should be generated for the entities in the returned collection. The standard may call this out somewhere, but I am not able to find it. Extend section https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_OperationResult  to include function results - could be similar to containment case, including the parameter values in the canonical URL A function returns a collection of entities that do not have keys - In this case, I believe that these entities should be considered [transient entities] ( http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_TransientEntities ) and that the portion of the standard that talks about entity-ids should call out that transient entities do not have an entity-id.

      Description

      A function can return a collection of an entity where that entity does not have a key defined. Keys are only required for [entity sets and multivalued navigation properties](https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html#_Toc38530354):

       > In order to be specified as the type of an entity set or a collection-valued containment navigation property, the entity type MUST either specify a key or inherit its key from its base type.
      [The standard](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_EntityIdsandEntityReferences) also says:

      > entities are also uniquely identified by a durable, opaque, globally unique entity-id
      > ...
      > Services are strongly encouraged to use the canonical URL for an entity

      So, my conclusion is that an entities returned in a collection by a function should have entity-ids. However, looking at how to create the canonical URL for an entity, the [standard says this](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_CanonicalURL):

      > the canonical form of an absolute URL identifying a non-contained entity is formed by adding a single path segment to the service root URL. The path segment is made up of the name of the entity set associated with the entity followed by the key predicate identifying the entity within the collection.

      It appears that an assumption is made that non-contained entities must exist within an entity set. However, entities that only exist as the result of a function may not have any entity set defined. So, it appears that there is no entity-id for the entities returned from a function, despite the standard declaring that entities have a durable, opaque, globally unique entity-id which can be exposed by following the canonical URL conventions.

        Attachments

          Activity

            People

            • Assignee:
              mikep Michael Pizzo
              Reporter:
              gdebruin Garrett DeBruin
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: