Skip to content
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

.includes() does not care about has_one-relation #389

Open
ryabrody opened this issue Jul 15, 2020 · 0 comments
Open

.includes() does not care about has_one-relation #389

ryabrody opened this issue Jul 15, 2020 · 0 comments

Comments

@ryabrody
Copy link
Contributor

ryabrody commented Jul 15, 2020

When we have following structure:

{
  "href": "http://api.test/localch-accounts/p62qM5p0NK_qryO52Ze",
  "id": "p62qM5p0NK_qryO52Ze",
  ...
  "language": "de",
  "created_date": "2015-06-30T09:54:59.858+02:00",
  "claims": {
    "href": "http://api.test/localch-accounts/p62qM5p0NK_qryO52Ze/claims",
    "items": [
      {
        "href": "http://api.test/localch-accounts/p62qM5p0NK_qryO52Ze/claims/A00OhenWd_Z5RWnxDE7mqA",
        "localch_account": {
          "href": "http://api.test/localch-accounts/p62qM5p0NK_qryO52Ze"
        },
        "place": {
          "href": "http://api.test/places/A00OhenWd_Z5RWnxDE7mqA"
        },
   ...
}

Then one claim can have one place.
When we now use include:

User.includes([claims: :place]).find('p62qM5p0NK_qryO52Ze')

LHS does not know if the relation between claims and place is singular it always presumes that the relation is plural and requests the first brach of places with:

GET http://api.test/places/A00OhenWd_Z5RWnxDE7mqA?limit=100

As the relation between place and claims is singular i would expect that LHS requests the place as following:

GET http://api.test/places/A00OhenWd_Z5RWnxDE7mqA

LHS should not do limit=100 when in the model thehas_one relation explicitly is set as described here: https://github.com/local-ch/lhs#has_one.

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

No branches or pull requests

1 participant