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

Possibility to use where for where in clause with tests #15219

Closed
wants to merge 1 commit into from
Closed

Possibility to use where for where in clause with tests #15219

wants to merge 1 commit into from

Conversation

evsign
Copy link

@evsign evsign commented Sep 1, 2016

Just a way to use where for building where in sql clause)
How to use:

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

All of these callings will be transformed in select * from table where "id" in (?, ?, ?)

@evsign evsign changed the title possibility to use where for where in clause with tests Possibility to use where for where in clause with tests Sep 1, 2016
@taylorotwell
Copy link
Member

Prefer people just explicitly call whereIn.

@evsign
Copy link
Author

evsign commented Sep 2, 2016

@taylorotwell I too, but i thought its not about what we prefer, but about what people could use) I thought only about ease of use and intuitively behavior for people, and this not forcing using one method against another.
Thanks)

@crynobone
Copy link
Member

crynobone commented Sep 2, 2016

I thought only about ease of use and intuitively behavior for people, and this not forcing using one method against another.

User::where('id', '!=', [1, 2, 3])->get();

Intuitively, you would expect this to output SELECT * FROMusersWHERE id NOT IN (1, 2, 3), but this PR make it output SELECT * FROMusersWHERE id IN (1, 2, 3).

What happen when you use <, >, >=, or <=? Simply parsing it as WHERE id IN (1, 2, 3) would be confusing for many people, as this would be an unexpected behaviour.

@evsign
Copy link
Author

evsign commented Sep 2, 2016

@crynobone Thanks. I reworked this issue and now:

$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 (?, ?, ?)
and

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

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

All another callings will be with default behavior.

@taylorotwell may i send pr again with fixes for this feature? or this already not under consideration?)

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.

3 participants