diff --git a/lib/searchkick/relation.rb b/lib/searchkick/relation.rb index a5f78d9..1d7d575 100644 --- a/lib/searchkick/relation.rb +++ b/lib/searchkick/relation.rb @@ -105,6 +105,15 @@ module Searchkick self end + def unscope(*args) + spawn.unscope!(*args) + end + + def unscope!(*args) + @options = options.except(*args) + self + end + # TODO make more efficient if loaded def pluck(*fields) result = select(*fields).load(false) diff --git a/test/relation_test.rb b/test/relation_test.rb index 18a2525..bf4b698 100644 --- a/test/relation_test.rb +++ b/test/relation_test.rb @@ -28,6 +28,11 @@ class RelationTest < Minitest::Test assert_search_relation ["Red"], Product.search("red").where(store_id: 1).unscoped end + def test_unscope + store_names ["Red", "Blue"] + assert_search_relation ["Red"], Product.search("red").where(store_id: 1).unscope(:where) + end + def test_pluck store_names ["Blue", "Red"] assert_equal ["Blue", "Red"], Product.order(:name).pluck(:name) if defined?(ActiveRecord) -- libgit2 0.21.0