diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 7b0d6e2de1..9ec926a66e 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -448,8 +448,16 @@ module Arel end end - def visit_Arel_Nodes_Extract o - "EXTRACT(#{o.field.to_s.upcase} FROM #{visit o.expr})#{o.alias ? " AS #{visit o.alias}" : ''}" + def visit_Arel_Nodes_Extract o, collector + collector << "EXTRACT(#{o.field.to_s.upcase} FROM " + collector = visit o.expr, collector + collector << ")" + if o.alias + collector << " AS " + visit o.alias, collector + else + collector + end end def visit_Arel_Nodes_Count o, collector |