New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
->cache(true)->sum('attribute') in mysql doesn't work. #17349
Comments
Is that MySQL specific? Does it depend on how cache is configured? |
Which version of Yii are you using? |
Updated to 2.0.20 looks liek now it works except: ->cache(true)->sum('HOUR(TIMEDIFF(created, completed))') This is not being cached |
How do you know that it's not caching? |
If I remove |
Do you have a cache configured? |
Hi ! Even if this issue is old, i face the same problem, so i'll put what i found here, in case that can help someone :) I believe the In that case, When checking the cache, |
Could you prepare new issue with that? |
After some more digging I was kinda right. The query returns The part that fails seems to be this one: if (is_array($result) && isset($result[0])) {
Yii::debug('Query result served from cache', 'yii\db\Command::query');
return $result[0];
} (in
Changing to if (is_array($result) && array_key_exists(0, $result)) {
Yii::debug('Query result served from cache', 'yii\db\Command::query');
return $result[0];
} fix the issue for me (I have no clue if it breaks anything). Should i still create a new issue? |
What steps will reproduce the problem?
->cache(true)->sum('attribute') in mysql doesn't work.
->cache(true)->one() - works
What is the expected result?
doing 100x ->cache(true)->sum('attribute') would do sql query only 1 time
What do you get instead?
sql query is executed 100x times
Additional info
The text was updated successfully, but these errors were encountered: