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

[9.x] Restore v8 behaviour of base query for relations #41923

Merged
merged 1 commit into from
Apr 11, 2022

Conversation

tpetry
Copy link
Contributor

@tpetry tpetry commented Apr 11, 2022

As commented on #41918 I found a new inconsistency in the Laravel 8.x and 9.x implementation with the fix by @driesvints.

In Laravel v8 the implementation for getBaseQuery was:

public function getBaseQuery()
{
    return $this->query->getQuery();
}

With the recently merged fix it's now the following which is different (it's now applying the scope!):

public function getBaseQuery()
{
    return $this->toBase();
}

public function toBase()
{
    return $this->query->applyScopes()->getQuery();
}

I restored the exact behavior of Laravel 8.x that getBaseQuery and toBase are both operating directly on the Eloquent\Builder object. So any change in Eloquent\Builder::toBase() is also automatically reflected on Relationship::toBase() as in Laravel 8.x.

Copy link
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

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

This probably indeed is the better fix. Thanks @tpetry.

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.

None yet

3 participants