jarektkaczyk / eloquence-base

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

Searchable: SQLSTATE[HY093]: Invalid parameter number #28

Open ghost opened 4 years ago

ghost commented 4 years ago

I'm not sure under which conditions this happens, this commit from Laravel 7.8.0 update breaks some search queries: https://github.com/laravel/framework/pull/32531/commits/70d7ba1175b6e54eb2abe82cea8f1e04fd7c4d69

joegrace commented 3 years ago

I'm not sure under which conditions this happens, this commit from Laravel 7.8.0 update breaks some search queries: laravel/framework@70d7ba1

@studmon After I spent the good portion of today and yesterday messing around with this, I found it was related to this core laravel commit: https://github.com/laravel/framework/commit/70d7ba1175b6e54eb2abe82cea8f1e04fd7c4d69

For some reason the bindings get reset (as you can see from that commit) when you call select() :-( So all of the work that eloquence did putting all the parameters together with the placeholders in the query all gets blown away and reset.

If you are using select() in your eloquent query, I would recommend calling the select() before search() and if you can, I would call select before any other eloquent methods.

-Joe