Skip to content

Commit

Permalink
Must support aliases for OVER operator.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Staubo committed Feb 23, 2012
1 parent 2db4ec6 commit 74aadec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/arel/nodes/over.rb
Expand Up @@ -2,6 +2,8 @@ module Arel
module Nodes

class Over < Binary
include Arel::AliasPredication

def initialize(left, right = nil)
super(left, right)
end
Expand Down
9 changes: 9 additions & 0 deletions test/nodes/test_over.rb
@@ -1,6 +1,15 @@
require 'helper'

describe Arel::Nodes::Over do
describe 'as' do
it 'should alias the expression' do
table = Arel::Table.new :users
table[:id].count.over.as('foo').to_sql.must_be_like %{
COUNT("users"."id") OVER () AS foo
}
end
end

describe 'with literal' do
it 'should reference the window definition by name' do
table = Arel::Table.new :users
Expand Down

0 comments on commit 74aadec

Please sign in to comment.