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

[BUG]:ORM Model::getRelated not reusing already fetched relations #16409

Open
rudiservo opened this issue Aug 18, 2023 · 1 comment
Open

[BUG]:ORM Model::getRelated not reusing already fetched relations #16409

rudiservo opened this issue Aug 18, 2023 · 1 comment
Labels
bug A bug report status: unverified Unverified

Comments

@rudiservo
Copy link
Contributor

Describe the bug
Model::getRelated() does not reuse already fetched relations that are populated in Model::related and Model::dirtyRelated.
getRelated always fetches fresh relations.
This makes requests slower and the Database heavier, normally there is no advantage by doing this, it only makes the request longer and the probability of a changed row while executing the request to happen, this is already almost impossible with the expected time of a request to be in the milliseconds.

Expected behavior
By default getRelated should reuse the relations in these arrays if not instructed otherwise.
Modell has refresh() to update the current model instance, ResultSet does not have this ability yet.

@ZanMaticPratnemer
Copy link

It would be great if the pull request for this issue was merged.
I also noticed this but didn't recognize it as a bug so I just extended the models __get() and getRelated() methods to perform the same check as in the pull request and directly return related[$alias] or dirtyRelated[$alias]. That fit the behavior that we expected and fixed this use case for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: unverified Unverified
Projects
None yet
Development

No branches or pull requests

2 participants