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

Allow referencing properties of "outer" entity in expressions nested within $expand

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.01_CS01
    • Fix Version/s: V4.01_CS02
    • Component/s: Protocol
    • Labels:
    • Environment:

      Proposed

    • Proposal:
      Hide

      Parameter aliases can be defined within $expand, and as they are evaluated upon assignment $this can be assigned to a "parameter" alias to solve the problem at hand:

      GET Foo?$expand=Bar(@b=$this;$expand=Baz($filter=Qux eq @b/Qux))
      

      Add an example in Protocol 11.2.6.1.3 Parameter Aliases

      Change "literals" to "values" in last paragraph of 11.2.6.1.3
       

      Show
      Parameter aliases can be defined within $expand, and as they are evaluated upon assignment $this can be assigned to a "parameter" alias to solve the problem at hand: GET Foo?$expand=Bar(@b=$ this ;$expand=Baz($filter=Qux eq @b/Qux)) Add an example in Protocol 11.2.6.1.3 Parameter Aliases Change "literals" to "values" in last paragraph of 11.2.6.1.3  
    • Resolution:
      Show
      https://www.oasis-open.org/committees/download.php/64946/odata-v4.01-wd06-part1-protocol-2019-03-22.docx  

      Description

      Expressions in query options nested within $expand already can reference the instance identified by the resource path via the symbolic literal $it.
      What's missing is in case of multiple nesting levels of $expand to reference the "next outer" instance.

      Artificial example: expand all Bars that have the same Baz as the current instance of Foo

      GET Foo?$expand=Bar($filter=Baz eq $it/Baz)
      

      What if I want to do this one level down: expand all Bazes that have the same Qux as the current expanded Bar's Qux

      GET Foo?$expand=Bar($expand=Baz($filter=Qux eq $outer/Qux))
      

      Note: $up is basically the .. operator in Unix file systems.

      Less artificial example: a service with temporal entity sets for Employee, WorkAssignment, and Department. I want to request employees and their work assignments over a period of time to see all changes in data, and want to expand the department with the snapshot state at the beginning of each work assignment because changes to the department are not of interest:

      GET Employees?$from=2010-01-01&$to=2019-02-28&$expand=WorkAssignments($expand=Department($at=$outer/@Temporal.From))
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              handl Ralf Handl
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: