Filebase
Filebase copied to clipboard
Duplicated results using orderBy and limit with cache enabled
Hey there!
With cache enabled, the following query will return the right results the first time it's called, but will show duplicate results from then on.
$db->query()->orderBy('__created_at', 'DESC')->limit(6)->resultDocuments();
It appears that the parameter in 'orderBy' can be anything for this bug to appear.
(Sorry for editing this issue 100 times as I kept finding problems / solutions and quickly debunk them after that ;)
@AdriaandeJongh Hi, can you share example data of what you're seeing in the results or even a print_r
of the output. I've tested this using resultDocuments()
and results()
but was unable to reproduce the issue of duplicated results. Are you saying you're seeing double results in the cached results?
(Sorry again for editing this issue a number of times as I'm discovering what is actually the issue.)
It appears the issue is with limit(6)
. The following files are versions of the cache file resulting from the query in the original post (renamed from .json to .txt so github would take them). So file 1.txt appeared in the cache folder after running the query once, file 2.txt after running it twice, and so on.
1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt
EDIT: Note that the expected order of the result of the query is: degoma, startlearning, 3xblast, excalisoft, vertigogames, spaghetti-games, which is only correctly displayed in the cache file after running the query twice. Not the first time, and not any time after the second time.
I can confirm I also experience this issue. When I have the cache enabled, every time I press refresh when using the limit I get duplication.
Have sombody a solution or workaround for this?
I have the same problem, removing the limit
from the query seems to help but i need a limit..
Else i have to deactivate the cache..