Permalink
Browse files

Include Arel::Predicates to Arel::Nodes::Function so you can do table…

…[:id].count.eq(2)
  • Loading branch information...
1 parent 58c3d1d commit 00d1482fefa1cf9c3753b58f4fe9b580c52ae935 @samuelkadolph samuelkadolph committed May 27, 2011
Showing with 10 additions and 2 deletions.
  1. +1 −0 lib/arel/nodes/function.rb
  2. +0 −2 lib/arel/nodes/named_function.rb
  3. +9 −0 test/nodes/test_count.rb
@@ -2,6 +2,7 @@ module Arel
module Nodes
class Function < Arel::Nodes::Node
include Arel::Expression
+ include Arel::Predications
attr_accessor :expressions, :alias, :distinct
def initialize expr, aliaz = nil
@@ -3,8 +3,6 @@ module Nodes
class NamedFunction < Arel::Nodes::Function
attr_accessor :name
- include Arel::Predications
-
def initialize name, expr, aliaz = nil
super(expr, aliaz)
@name = name
View
@@ -15,4 +15,13 @@
}
end
end
+
+ describe "eq" do
+ it "should compare the count" do
+ table = Arel::Table.new :users
+ table[:id].count.eq(2).to_sql.must_be_like %{
+ COUNT("users"."id") = 2
+ }
+ end
+ end
end

0 comments on commit 00d1482

Please sign in to comment.