aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/arel/attributes/attribute.rb4
-rw-r--r--spec/arel/attributes/attribute_spec.rb7
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/arel/attributes/attribute.rb b/lib/arel/attributes/attribute.rb
index 6087dc8e52..464d78188a 100644
--- a/lib/arel/attributes/attribute.rb
+++ b/lib/arel/attributes/attribute.rb
@@ -9,8 +9,8 @@ module Arel
Nodes::In.new self, other
end
- def count
- Nodes::Count.new [self]
+ def count distinct = false
+ Nodes::Count.new [self], distinct
end
end
diff --git a/spec/arel/attributes/attribute_spec.rb b/spec/arel/attributes/attribute_spec.rb
index f9eb56391e..d6f07f8d99 100644
--- a/spec/arel/attributes/attribute_spec.rb
+++ b/spec/arel/attributes/attribute_spec.rb
@@ -8,6 +8,13 @@ module Arel
relation = Table.new(:users)
relation[:id].count.should be_kind_of Nodes::Count
end
+
+ it 'should take a distinct param' do
+ relation = Table.new(:users)
+ count = relation[:id].count(nil)
+ count.should be_kind_of Nodes::Count
+ count.distinct.should be_nil
+ end
end
describe '#eq' do