ActiveRecord#minimum generates different column names with group by

With Rails 4.1.7 I want to build a generic query calculating the minimum of a ‘position’ field. The ‘group by’ of this query is dynamic. There may be one or not, like so:
grouping=[]“minimum_position>1”).minimum(:position).each do |item, min_pos|

I found out that if there is a grouping“minimum_position>1”).minimum(:position) will generate:
SELECT MIN(items.position) AS minimum_position, parent_type AS parent_type, parent_id AS parent_id, position AS position FROM items GROUP BY parent_type, parent_id, position HAVING minimum_position>1
And if there is no grouping: Item.having(“minimum_position>1”).minimum(:position) will generate:
SELECT MIN(items.position) AS minimum_id FROM items HAVING minimum_position>1

which leads to an exception error as there is no field ‘minimum_position’

Why do these two queries do not generate the same column name for the Minimum(:field) function?

Would it not be more Rails like to generate the same column name? Would it be worth proposing it as an issue?



Off course, without a GROUP BY there should not be a HAVING though the functionality still stands and a WHERE could be used in stead. MySQL just accepts it.