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

Does not re-give relationships in query type a.b.c #576

Closed
PHPist opened this issue Aug 4, 2023 · 7 comments
Closed

Does not re-give relationships in query type a.b.c #576

PHPist opened this issue Aug 4, 2023 · 7 comments

Comments

@PHPist
Copy link

PHPist commented Aug 4, 2023

Models relationships

Houses HasMany  Apartments	
Apartments BelongsTo Owner
Apartments BelongsTo House
Owner HasMany  Phones

GET /houses/1?include=apartments.owner.phones returns

https://jsoneditoronline.org/#left=cloud.15ee4ba500164dc9bce7386c5506263b&right=cloud.7126537776eb42c1bd1c35efdb49c4d8

Two apartments in the building (number 50, 88) belong to the same owner. The first object has owner.phones in the second one does not.
Alt text

example: https://github.com/PHPist/restify-test

@RuslanYakovlev
Copy link

This is relevant for me, can it be fixed?

@ibaskakovidurak
Copy link

I have the same problem... I hope guys you fix this bug as soon as possible

@npm-fork
Copy link

+1

@binaryk
Copy link
Collaborator

binaryk commented Sep 28, 2023

Hi @PHPist , thank you for the issue well documented.

Could you ensure please the json URL is correct?

image

@PHPist
Copy link
Author

PHPist commented Sep 28, 2023

https://jsoneditoronline.org/#left=cloud.7126537776eb42c1bd1c35efdb49c4d8

@binaryk
Copy link
Collaborator

binaryk commented Sep 29, 2023

The problem is here.

This was a performance enhancement to not load the same data twice from the DB.

Still looking into a good fix:

CleanShot 2023-09-29 at 18 17 56@2x

@PHPist
Copy link
Author

PHPist commented Sep 29, 2023

Thanks for the quick reply! Yes I saw that and assumed it was an optimization too. We even wanted to figure out how to flesh this out on the front end of the app. But the behavior is very unpredictable. So repeating the relationships would be the right thing to do. Like Laravel does (with, load).

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

5 participants