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

[5.7] Prevent unnecessary relationship queries #26992

Merged
merged 1 commit into from
Dec 29, 2018
Merged

[5.7] Prevent unnecessary relationship queries #26992

merged 1 commit into from
Dec 29, 2018

Conversation

staudenmeir
Copy link
Contributor

Prevents unnecessary queries when lazy loading empty relationships:

(new Post(['user_id' => null]))->user; // null
(new User)->posts;                     // []

MorphTo::getResults() is now handled by BelongsTo::getResults() (#8586).

This does not apply to custom relationship queries like (new User)->posts()->get().

I don't think we need additional tests for this. There are plenty of tests that verify relationship queries.

Fixes #25214, #24241, #20616 and laravel/ideas#748.

Copy link
Contributor

@brunogaspar brunogaspar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good 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

Successfully merging this pull request may close these issues.

4 participants