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.6] Add Builder::whereJsonNotContains() #24367

Merged
merged 1 commit into from
May 31, 2018
Merged

[5.6] Add Builder::whereJsonNotContains() #24367

merged 1 commit into from
May 31, 2018

Conversation

staudenmeir
Copy link
Contributor

@staudenmeir staudenmeir commented May 29, 2018

Adds whereJsonNotContains() to complement whereJsonContains() (#24330).

Or would you prefer whereJsonDoesntContain()?

EDIT: This isn't a breaking change because whereJsonContains() hasn't been released yet.

@sisve
Copy link
Contributor

sisve commented May 30, 2018

You're changing the method signature of whereJsonContains which is a breaking change. This indicates that the PR should target the master branch (the next release).

@staudenmeir
Copy link
Contributor Author

whereJsonContains() hasn't been released yet.

@sisve
Copy link
Contributor

sisve commented May 30, 2018

Ah, but I wouldn't admit to being wrong. But I was perhaps not fully correct. ;)

You're right, this wouldn't be a breaking change since it isn't released yet.

@staudenmeir
Copy link
Contributor Author

I wasn't implying that ;-) I should have mentioned it in the first post.

@taylorotwell taylorotwell merged commit 55a30f9 into laravel:5.6 May 31, 2018
@staudenmeir staudenmeir deleted the where-json-not-contains branch May 31, 2018 21:43
@cirdog
Copy link

cirdog commented Jun 7, 2018

Why not just let users use "whereIn" & "whereNotIn" on the surface and internally call "whereJsonContains" & "whereJsonNotContains" under the hood whenever the column name contains the "->" syntax?

It's more concise & unified as I myself treat the Query Builder as a "programming interface" of some sort.

@staudenmeir
Copy link
Contributor Author

staudenmeir commented Jun 7, 2018

There are two reasons:

  • whereIn() is the opposite of whereJsonContains():
    whereIn() checks whether the column value exists in the values provided by the user.
    whereJsonContains() checks whether the value provided by the user exists in the column.
  • When the column value is an array, the column selector wouldn't contain a ->.
    So Laravel wouldn't know that the user is querying a JSON column.

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

4 participants