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

Fix syntax for deleting links to support containment

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.0_CSD01
    • Fix Version/s: V4.0_CSD02
    • Component/s: ABNF, Protocol, URL Conventions
    • Labels:
      None
    • Environment:

      [Applied]

    • Proposal:
      Hide

      Define "the URL that represents the reference to the related entity" in a collection (used in section "11.5.6.2 Remove a Reference to an Entity" in [Protocol]) as the URL representing the relationships between two entities (defined in section "4.4 Addressing References Between Entities" in [URL]) with the id of the reference being deleted passed in the $id query option. For a to-one relationship, this is just the URL that represent the reference to the related entity (no need to add the id; in fact, it would be illegal)

      Note that this id can be relative to the service root.

      So, to delete a reference in a collection of related entities, you would do:

      DELETE ~Customers('ALFKI')/Orders/$ref?$id=Orders(1)

      Where http://myservice.svc/Orders(1) is the id of the order being removed from Customers(1).

      For containment, this would look like:

      DELETE ~Products(5)/OrderedIn/$ref?$id=Orders(1)/Lines(3)

      Not specifying the $id would be illegal (reserved for possibly doing set operations in a future version).

      To delete a reference in a to-1 relationship you omit the id:

      DELETE ~Orders(1)/Customer/$ref

      It is illegal to specify $id in this case, as the target identified by the path is a single entity reference, as opposed to a collection.

      Accepted: https://www.oasis-open.org/committees/download.php/49375/odata-meeting-39_on-20130530-minutes.html#odata-414

      Show
      Define "the URL that represents the reference to the related entity" in a collection (used in section "11.5.6.2 Remove a Reference to an Entity" in [Protocol] ) as the URL representing the relationships between two entities (defined in section "4.4 Addressing References Between Entities" in [URL] ) with the id of the reference being deleted passed in the $id query option. For a to-one relationship, this is just the URL that represent the reference to the related entity (no need to add the id; in fact, it would be illegal) Note that this id can be relative to the service root. So, to delete a reference in a collection of related entities, you would do: DELETE ~Customers('ALFKI')/Orders/$ref?$id=Orders(1) Where http://myservice.svc/Orders(1 ) is the id of the order being removed from Customers(1). For containment, this would look like: DELETE ~Products(5)/OrderedIn/$ref?$id=Orders(1)/Lines(3) Not specifying the $id would be illegal (reserved for possibly doing set operations in a future version). To delete a reference in a to-1 relationship you omit the id: DELETE ~Orders(1)/Customer/$ref It is illegal to specify $id in this case, as the target identified by the path is a single entity reference, as opposed to a collection. Accepted: https://www.oasis-open.org/committees/download.php/49375/odata-meeting-39_on-20130530-minutes.html#odata-414
    • Resolution:
      Show
      https://www.oasis-open.org/committees/download.php/49405/odata-v4.0-wd02-part1-protocol-2013-06-04.docx https://www.oasis-open.org/committees/download.php/49406/odata-v4.0-wd02-part2-url-conventions-2013-06-04.docx https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/ABNF/odata-abnf-construction-rules.txt?rev=340 https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/ABNF/odata-abnf-testcases.xml?rev=340 Accepted: https://www.oasis-open.org/committees/download.php/49557/odata-meeting-41_on-20130613_14-F2F-minutes.html#odata-414

      Description

      Today the syntax for deleting a link from Products(5) to the orderdetail whose id is 1 is as follows:

      DELETE ~Products(5)/OrderedIn(1)/$ref

      We did this as a shortcut to repeating the collection and id following the $ref.

      There are two problems with this syntax. First, it is semantically a bit weird in that Products(5)/OrderedIn/$ref represents the set of entity references of order details referenced by the OrderedIn nav prop of Products(5). More significantly, it doesn't work for containment scenarios, or anywhere there is no navigationpropertybinding, as the key appended to the nav property is not guaranteed to uniquely identify the related entity.

      The second problem is a manifestation of the first conceptual problem. In order to delete a relationship we need 3 pieces of information: (1) the source entity, (2) the navigation property, and (3) the id of the thing being no longer related. In a 1:1 or many:1 relationship the id of the thing being removed is implicit, but in many:many we need to specify which thing to unrelated. The current syntax assumes that this information can be derived by applying the key to the nav prop, but this alone is not sufficient.

      For collections, we could append id to the URL representing the collection of links, as in:
      DELETE ~Products(5)/OrderedIn/$ref/OrderDetails(1)
      for non-contained OrderDetails, or:
      DELETE ~Products(5)/OrderedIn/$ref/Orders(123)/Details(1)
      for contained OrderDetails

      For single-valued relationships we would simply omit the id, since it points to a single references (and is therefore not valid to index with an id)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mikep Michael Pizzo (Inactive)
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: