jarektkaczyk / eloquence-base

base for the Eloquence extensions + Searchable
https://softonsofa.com
MIT License
78 stars 71 forks source link

Eloquence builder breaks parameter grouping #35

Closed sergejostir closed 3 years ago

sergejostir commented 3 years ago

Laravel 7.29.3

Sofa\Eloquence\Builder

>>> App\Models\User::where('name', '=', 'John')->where(function ($query) { $query->where('votes', '>', 100) ->orWhere('title', '=', 'Admin'); })->toSql();
=> "select * from `users` where `name` = ? and (select * where `votes` > ? or `title` = ?) is null"

Illuminate\Database\Eloquent\Builder

>>> App\Models\User::where('name', '=', 'John')->where(function ($query) { $query->where('votes', '>', 100) ->orWhere('title', '=', 'Admin'); })->toSql();
=> "select * from `users` where `name` = ? and (`votes` > ? or `title` = ?)"

As you can see, when Eloquence is used, it starts a subquery instead of a parameter group.

marnickmenting commented 3 years ago

Is this related to #31 ?

sergejostir commented 3 years ago

It appears so. Closing this one as is a duplicate.