Closed officialmorse closed 3 years ago
Any movement on this? I have a very similar issue.
@officialmorse @joshuacashcalc Laravel versions?
I'm using laravel 6.0 and another project on laravel 8
@officialmorse @joshuacashcalc Laravel versions?
v8.24.0
@joshuacashcalc What version is bringing problems?
Sorry I should have been more specific. Laravel 8.26.1 and the latest version of this package. Laravel 6 has nothing to do with this project, apologies!
That should be fixed.
Unfortunately, raw queries will not be cached using ->selectSub()
Hi, firstly let me say I love the package. It Has saved a great deal of time improving efficiency within our app.
While implementing this within my setup I've noticed a couple of issues.
The
public function get($columns = ['*'])
andpublic function selectSub($query, $as)
methods implemented inRennokki\QueryCache\Query\Builder
handle parameters differently to\Illuminate\Database\Eloquent\Builder
public function get($columns = ['*'])
The method should be able to accept a single column as a string and then wrap this using the
Arr::wrap
helper as declared in\Illuminate\Database\Eloquent\Builder::get
.When the model does not need caching this is fine as the parent method is called immediately and the string is wrapped. Going through the
QueryCacheModule::getFromQueryCache
produces the following stack traceThis was previously mentioned in #46
public function selectSub($query, $as)
When passing a raw query as a string, the if statement used to check whether to append cache tags produces an error as the
get_class
is expecting an object to be passed.If you're happy for me to submit a PR I can make the necessary changes.
Thanks, Luke