When using the query builder, if you give eloquent a clause that ends up being an identity, something like
$foo = [];
$query->whereNotIn('column', $foo);
it translates that clause to 1=1
when it builds the query, at least for MySQL. Are there any config options to alter this behavior? I realize it would be ideal to check if $foo
is empty before adding it to the query, but I think it would make more sense to just ignore the clause instead of turning it into 1=1
so I would like to know if there is any way to control that.
>>> echo User::whereNotIn('id',[])->toSql()
select * from `users` where 1 = 1
I'd rather that just evaluate to
select * from `users`