You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found a issue with MySQL (or MariaDB in my case) and using sum aggregation.
The Primary keys on the DB query seem to be returned with string primary_keys. Which then does not match the primary_key of the given record for mapping the values.
As the tests only run against sqlite this issue does not seem present. But i thought it might be interesting for someone else.
You are corret. I know it's not a real fix, that's why i did not create a pull-request, but still found it might be usefull for someone else facing a similar issue.
I spent a couple hours debugging, why some numbers did not add up, until i fould thataggregate_hash was returning a hash with string-keys, for a model where primary-keys are integers. So every sum was retuning zero values.
It only happend with sum not any other method. Also it only happend in a real application using MariaDB, not with the tests in the gem itself (using SQLite).
Might rather be a issue in Activerecord or even Mysql driver, not sure - unfortunately i did not have more time to dig even deeper so far.
I found a issue with MySQL (or MariaDB in my case) and using
sum
aggregation.The Primary keys on the DB query seem to be returned with string primary_keys. Which then does not match the
primary_key
of the given record for mapping the values.As the tests only run against sqlite this issue does not seem present. But i thought it might be interesting for someone else.
My change can be seen here: https://github.com/maxigs/eager_group/blob/master/lib/eager_group/preloader.rb#L48
(I just copied the whole class into an initializer in my rails project for now, so i could test it with real database)
The text was updated successfully, but these errors were encountered: