8000 Nested $expand are not working · Issue #261 · flat3/lodata · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Nested $expand are not working #261
Closed
@Angelinsky7

Description

@Angelinsky7

Context

class Person {

  #[LodataRelationship]
    public function link()
    {
        return $this->hasOne(Link::class, 'id', 'link_id' );
    }

  #[LodataRelationship]
    public function tags(){
        return $this->hasMany(Tag::class);
    }
}

class Tag {
}

class Link {
  #[LodataRelationship]
    public function sublink()
    {
        return $this->hasOne(SubLink::class, 'id', 'sublink_id' );
    }
}

class Sublink {
}

Db

Table person{id, link_id}
Table tags{id}
Table link{id}
Table sublink{id}
Table person_tag{person_id,tag_id}

Request
http://localhost:8080/odata/Person?expand=link($expand=sublink)

Result
The result is the same with this request http://localhost:8080/odata/Person?expand=link the nested $expand is not used.

{
    {
  "@context": "http://localhost:8080/odata/$metadata#Gparent01s(link())",
  "value": [
    {
      "id": 1,
      "glink01_fk": 1,
      "cproperty01": "sed earum repellendus enim mollitia sit odit incidunt numquam a",
      "nproperty02": 318,
      "bproperty03": false,
      "dproperty04": "1988-04-24T01:47:09+00:00",
      "created_at": "2022-05-03T12:46:19+00:00",
      "updated_at": "2022-05-03T12:46:19+00:00",
      "link": {
        "id": 1,
        "sublink_id": 1,
        "link": "quis eum autem laboriosam qui cupiditate quod mollitia nihil repellendus",
        "values": "voluptas sed explicabo a at cum repellat sed repellendus eos",
        "created_at": "2022-05-03T12:46:19+00:00",
        "updated_at": "2022-05-03T12:46:19+00:00"
      }
    }
}

Expected result
The result should contains the Sublink entity when present in the relationship as expected (with the correct context) : https://docs.oasis-open.org/odata/odata/v4.01/os/part1-protocol/odata-v4.01-os-part1-protocol.html#sec_ExpandOptions

{
    {
  "@context": "http://localhost:8080/odata/$metadata#Gparent01s(link(Sublink()))"
  "value": [
    {
      "id": 1,
      "glink01_fk": 1,
      "cproperty01": "sed earum repellendus enim mollitia sit odit incidunt numquam a",
      "nproperty02": 318,
      "bproperty03": false,
      "dproperty04": "1988-04-24T01:47:09+00:00",
      "created_at": "2022-05-03T12:46:19+00:00",
      "updated_at": "2022-05-03T12:46:19+00:00",
      "link": {
        "id": 1,
        "sublink_id": 1,
        "link": "quis eum autem laboriosam qui cupiditate quod mollitia nihil repellendus",
        "values": "voluptas sed explicabo a at cum repellat sed repellendus eos",
        "created_at": "2022-05-03T12:46:19+00:00",
        "updated_at": "2022-05-03T12:46:19+00:00",
        "sublink" : {
           "id": 1,
           "sublink": "quis eum autem laboriosam qui cupiditate quod mollitia nihil repellendus".
           "prop1": 1231,
           "created_at": "2022-05-20T14:47:24+00:00",
           "updated_at": "2022-05-20T15:47:24+00:00",
         }
      }
    }
}

Version
"flat3/lodata": "^5.11"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0