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
Merged

[5.3] Allow scopes starting with or boolean #12918

merged 1 commit into from Apr 1, 2016

Conversation

acasar
Copy link
Contributor

@acasar 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
@taylorotwell
Copy link
Member

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants