Commit 4f3837a10d1995e215f7cae42b947b43d3cf3b50
1 parent
c174d142
Exists in
master
and in
1 other branch
Added where.not method to relation
Showing
4 changed files
with
22 additions
and
2 deletions
Show diff stats
lib/searchkick.rb
lib/searchkick/relation.rb
... | ... | @@ -89,8 +89,12 @@ module Searchkick |
89 | 89 | end |
90 | 90 | |
91 | 91 | # experimental |
92 | - def where(value) | |
93 | - clone.where!(value) | |
92 | + def where(value = NO_DEFAULT_VALUE) | |
93 | + if value == NO_DEFAULT_VALUE | |
94 | + Where.new(self) | |
95 | + else | |
96 | + clone.where!(value) | |
97 | + end | |
94 | 98 | end |
95 | 99 | |
96 | 100 | # experimental | ... | ... |
test/where_test.rb
... | ... | @@ -97,6 +97,10 @@ class WhereTest < Minitest::Test |
97 | 97 | |
98 | 98 | # rewhere |
99 | 99 | assert_search_relation ["Product A", "Product C"], Product.search("product").where(in_stock: true).rewhere(backordered: true) |
100 | + | |
101 | + # not | |
102 | + assert_search_relation ["Product C", "Product D"], Product.search("product").where.not(in_stock: true) | |
103 | + assert_search_relation ["Product C"], Product.search("product").where.not(in_stock: true).where(backordered: true) | |
100 | 104 | end |
101 | 105 | |
102 | 106 | def test_where_string_operators | ... | ... |