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

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

      Proposed

    • 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  
    • Show
      https://www.oasis-open.org/committees/download.php/64946/odata-v4.01-wd06-part1-protocol-2019-03-22.docx  

      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))
      

            Assignee:
            Unassigned
            Reporter:
            handl
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: