Skip to content
Browse files

Must support aliases for OVER operator.

  • Loading branch information...
1 parent 2db4ec6 commit 74aadecc4f58e73704ac6a6fdaf25e48832374cf Alexander Staubo committed Feb 23, 2012
Showing with 11 additions and 0 deletions.
  1. +2 −0 lib/arel/nodes/over.rb
  2. +9 −0 test/nodes/test_over.rb
View
2 lib/arel/nodes/over.rb
@@ -2,6 +2,8 @@ module Arel
module Nodes
class Over < Binary
+ include Arel::AliasPredication
+
def initialize(left, right = nil)
super(left, right)
end
View
9 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

0 comments on commit 74aadec

Please sign in to comment.
Something went wrong with that request. Please try again.