Description
Issue
I get the same results for different queries using whereRaw with added bindings when called on the same column. For example:
SomeModel::whereRaw('somecolumn = ?', ['somevalue'])->get();
SomeModel::whereRaw('somecolumn = ?', ['anothervalue'])->get();
SomeModel::whereRaw('somecolumn = ?', ['yetanothervalue'])->get();
The second and third query always returns the result of the first query.
I did dug around in the code. I noticed that CacheKey
does not include the value of the binding given to the whereRaw
method. This results in a string that is the same for these three queries, thus causing trouble.
I guess adding a $this->getValuesClause($where)
to https://github.com/GeneaLabs/laravel-model-caching/blob/master/src/CacheKey.php#L172 should fix the problem? Haven't been able to spend much time on it so please correct me if I'm wrong or if this will break stuff. I am willing to create a PR to fix this!
Environment
Laravel Version: 5.6.16
Laravel Model Caching Package Version: 0.2.52
PHP Version: 7.2.2
Homestead Version: n/a
Operating System & Version: Debian 9.3