aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/arel/nodes/function.rb1
-rw-r--r--test/nodes/test_sum.rb9
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/arel/nodes/function.rb b/lib/arel/nodes/function.rb
index 733a00df46..182dfa7329 100644
--- a/lib/arel/nodes/function.rb
+++ b/lib/arel/nodes/function.rb
@@ -3,6 +3,7 @@ module Arel
class Function < Arel::Nodes::Node
include Arel::Predications
include Arel::WindowPredications
+ include Arel::OrderPredications
attr_accessor :expressions, :alias, :distinct
def initialize expr, aliaz = nil
diff --git a/test/nodes/test_sum.rb b/test/nodes/test_sum.rb
index d65cd31d4b..d387e7f9ef 100644
--- a/test/nodes/test_sum.rb
+++ b/test/nodes/test_sum.rb
@@ -21,4 +21,13 @@ describe Arel::Nodes::Sum do
assert_equal 2, array.uniq.size
end
end
+
+ describe 'order' do
+ it 'should order the sum' do
+ table = Arel::Table.new :users
+ table[:id].sum.desc.to_sql.must_be_like %{
+ SUM("users"."id") DESC
+ }
+ end
+ end
end