Do we need set mysql function alias by default #154

timsly opened this Issue Dec 18, 2012 · 1 comment


None yet
2 participants

timsly commented Dec 18, 2012

I tried to build complex query using arel(add sum into having)
But due to default aliases i couldn't make it
So i had to use smth like

condition = arel_table[:time].sum
condition.alias = nil


Also i couldn't pass nil or false to as method, because it try to build SqlLiteral object, see here

I thought that we can allow nil as as param, but also we can remove those default aliases(of course if it's not break smth) and set alias explicitly

This is an old issue but this also broke an attempt at using a window function for me. I needed to do:

Arel.sql('sum(count(*)) over (order by min_timestamp) as count')

but tried

window =
min_arrivals_cte['count(*)'].sum.over(window)). # Tried in Arel, but doesn't work, introduces an alias

The latter produces the invalid SQL:
SUM("min_arrival"."count(*)") AS sum_id OVER (ORDER BY min_commented_time)

the AS sum_id is a default alias which breaks the window function syntax:
ERROR: syntax error at or near "OVER"

min_arrivals_cte['*'].count.sum.over(window) also does not work, but I am not sure if it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment