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.4] Possibility to use where for where in clause #15266

Closed
wants to merge 1 commit into from
Closed

[5.4] Possibility to use where for where in clause #15266

wants to merge 1 commit into from

Conversation

evsign
Copy link

@evsign evsign commented Sep 4, 2016

I didn't get a reply in #15219 and decide to pr again. Close so close)

$builder->where('id', [1,2,3]);
$builder->where('id', 'in', [1,2,3]);
$builder->where('id', '=', [1,2,3]);

will produce: select * from table where "id" in (?, ?, ?)

$builder->where('id', '!=', [1,2,3]);
$builder->where('id', 'not in', [1,2,3]);

will produce: select * from table where "id" not in (?, ?, ?)

@GrahamCampbell GrahamCampbell changed the title Possibility to use where for where in clause [5.3] Possibility to use where for where in clause Sep 4, 2016
@GrahamCampbell GrahamCampbell changed the base branch from 5.3 to master September 5, 2016 08:07
@GrahamCampbell GrahamCampbell changed the title [5.3] Possibility to use where for where in clause [5.4] Possibility to use where for where in clause Sep 5, 2016
* Add array of bindings to the query.
*
* @param array $values
* @param $type
Copy link
Member

Choose a reason for hiding this comment

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

invalid doc

@fernandobandeira
Copy link
Contributor

fernandobandeira commented Sep 5, 2016

Not sure if we need this.

Also this syntax:

$builder->where('id', [1,2,3]);

Could be used for another purpose in the future instead of calling a whereIn.
Maybe a json query $build->where('jsonColumn', ['badge' => 'black']);
Would turn into something like $build->where('jsonColumn->badge', 'black');

Not saying that we should accept this syntax but we would be able to if the syntax is not used for anything else.

Also the same applies to

$builder->where('id', '=', [1,2,3]);
$builder->where('id', '!=', [1,2,3]);

But this seems nice:

$builder->where('id', 'in', [1,2,3]);
$builder->where('id', 'not in', [1,2,3]);

@taylorotwell
Copy link
Member

Please just use whereIn explicitly.

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.

4 participants