I know PostgreSQL, unlike MySQL, requires to list all selected fields in the group by
clause when using aggregate functions, e.g.
Transaction.select('sum(amount), category_id').group('category_id')
Fair enough. But when I try to eager load an association, e.g.
Transaction.select('sum(amount), categories.name').includes(:category).group('categories.name')
it doesn't work because you haven't included all fields of both models in the group by clause.
Is there a way to avoid having to list all fields of the models, or should I consider accepting the N+1 queries? (I don't think listing 30 fields makes sense when I only need 2...)