Reported by Penny, it seems that we are trying to get ratings for forums/glossaries/data activities configured as "no ratings".
This causes the function get_aggregation_method() to be called with incorrect aggregation method that leads to "null" value returned and PostgreSQL (and potentially others) breaking badly.
So, the correct behavior should be to avoid completely any fetch of ratings if the activity is set to "no ratings".
In the mean time, I've added one debugging message to the get_aggregation_method() function to make it easy to detect wrong uses (and default to AVG to have always one correct answer there).
So, right now it's working, but all those wrong calls must be avoided (in the module or in the get_ratings() function).