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 1 commit into from Apr 1, 2016


Copy link

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
continuous-integration/travis-ci/pr The Travis CI build passed

This comment has been minimized.

Copy link

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
None yet
2 participants
You can’t perform that action at this time.