diff --git a/lib/ransack/adapters/active_record/3.0/context.rb b/lib/ransack/adapters/active_record/3.0/context.rb index 9a58f0d..56e5fbe 100644 --- a/lib/ransack/adapters/active_record/3.0/context.rb +++ b/lib/ransack/adapters/active_record/3.0/context.rb @@ -13,8 +13,7 @@ module Ransack def evaluate(search, opts = {}) viz = Visitor.new - relation = @object.where(viz.accept(search.base)).order(viz.accept(search.sorts)) - opts[:distinct] ? relation.select("DISTINCT #{@klass.quoted_table_name}.*") : relation + @object.where(viz.accept(search.base)).order(viz.accept(search.sorts)) end def attribute_method?(str, klass = @klass) diff --git a/lib/ransack/adapters/active_record/context.rb b/lib/ransack/adapters/active_record/context.rb index 9311eba..4932853 100644 --- a/lib/ransack/adapters/active_record/context.rb +++ b/lib/ransack/adapters/active_record/context.rb @@ -11,8 +11,7 @@ module Ransack def evaluate(search, opts = {}) viz = Visitor.new - relation = @object.where(viz.accept(search.base)).order(viz.accept(search.sorts)) - opts[:distinct] ? relation.select("DISTINCT #{@klass.quoted_table_name}.*") : relation + @object.where(viz.accept(search.base)).order(viz.accept(search.sorts)) end def attribute_method?(str, klass = @klass) diff --git a/spec/ransack/search_spec.rb b/spec/ransack/search_spec.rb index b2df7fa..c1910e1 100644 --- a/spec/ransack/search_spec.rb +++ b/spec/ransack/search_spec.rb @@ -129,12 +129,6 @@ module Ransack where.to_sql.should match /\("people"."name" = 'Ernie' OR "children_people"."name" = 'Ernie'\) AND \("people"."name" = 'Bert' OR "children_people"."name" = 'Bert'\)/ end - it 'returns distinct records when passed :distinct => true' do - search = Search.new(Person, :g => [{:m => 'or', :comments_body_cont => 'e', :articles_comments_body_cont => 'e'}]) - search.result.should have(920).items - search.result(:distinct => true).should have(330).items - search.result.all.uniq.should eq search.result(:distinct => true).all - end end describe '#sorts=' do