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.3] Allow scopes starting with or boolean #12918

Merged
merged 1 commit into from Apr 1, 2016

Conversation

@acasar
Copy link
Contributor

acasar commented Mar 29, 2016

Based on the feedback I am proposing a minor change in query scopes:

// Lets say we have the following scope:
public function scopeOrActive($query)
{
    $query->orWhere('active', 1);
}

// And we execute the following query:
User::where('foo', 'bar')->orActive();

Since in 5.2 scopes are automatically nested to avoid any confusion in logical order of the operators, we would get the following sql:

/* Note that the "or" boolean was replaced with "and" */
select * from "users" where ("foo"="bar") and ("active"="1")

However, it seems that some people would prefer the leading boolean to be respected:

select * from "users" where ("foo"="bar") or ("active"="1")

I am targeting this PR to 5.3, since it's a minor BC break.

@taylorotwell taylorotwell merged commit 7ebcb06 into laravel:master Apr 1, 2016
2 checks passed
2 checks passed
StyleCI The StyleCI analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@taylorotwell

This comment has been minimized.

Copy link
Member

taylorotwell commented Apr 1, 2016

Can you send a PR to the 5.3 documentation (master branch) noting this change in the upgrade guide?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.