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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Angelinsky7 opened this issue May 20, 2022 · 3 comments
Closed

Nested $expand are not working #261

Angelinsky7 opened this issue May 20, 2022 · 3 comments

Comments

@Angelinsky7
Copy link

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"

@27pchrisl
Copy link
Contributor

Again I think this is #255 (comment) where the nested query parameters were not being correctly used by sub-requests. Again could you confirm whether or not the changes in the branch help? Thankyou!

@27pchrisl
Copy link
Contributor

And the incorrect context construction should also now be resolved.

@27pchrisl
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants
0