diff options
-rw-r--r-- | lib/arel.rb | 2 | ||||
-rw-r--r-- | lib/arel/nodes/count.rb | 2 | ||||
-rw-r--r-- | spec/arel/nodes/count_spec.rb | 6 |
3 files changed, 9 insertions, 1 deletions
diff --git a/lib/arel.rb b/lib/arel.rb index 4772e9f4b0..d1c2e44567 100644 --- a/lib/arel.rb +++ b/lib/arel.rb @@ -8,6 +8,7 @@ require 'arel/compatibility/wheres' #### these are deprecated # The Arel::Relation constant is referenced in Rails require 'arel/relation' +require 'arel/expression' #### require 'arel/tree_manager' @@ -21,7 +22,6 @@ require 'arel/nodes' require 'arel/deprecated' require 'arel/sql/engine' require 'arel/sql_literal' -require 'arel/expression' #### require 'arel/visitors/to_sql' diff --git a/lib/arel/nodes/count.rb b/lib/arel/nodes/count.rb index 2f220dbfc8..354659ef70 100644 --- a/lib/arel/nodes/count.rb +++ b/lib/arel/nodes/count.rb @@ -1,6 +1,8 @@ module Arel module Nodes class Count < Arel::Nodes::Function + include Arel::Expression + attr_accessor :distinct def initialize expr, distinct = false, aliaz = nil diff --git a/spec/arel/nodes/count_spec.rb b/spec/arel/nodes/count_spec.rb index 7013a16429..185b4d8eb9 100644 --- a/spec/arel/nodes/count_spec.rb +++ b/spec/arel/nodes/count_spec.rb @@ -1,6 +1,12 @@ require 'spec_helper' describe Arel::Nodes::Count do + describe 'backwards compatibility' do + it 'must be an expression' do + Arel::Nodes::Count.new('foo').should be_kind_of Arel::Expression + end + end + describe "as" do it 'should alias the count' do table = Arel::Table.new :users |