Skip to content

Commit

Permalink
Added warning for exists - #1686
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jul 11, 2024
1 parent 6ce2f6a commit 2eda775
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 5.4.0 (unreleased)

- Added support for scripting to `where` option
- Added warning for `exists`
- Added warning for full reindex and `:queue` mode
- Dropped support for Ruby < 3.1

Expand Down
5 changes: 5 additions & 0 deletions lib/searchkick/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,11 @@ def where_filters(where)
when :in
filters << term_filters(field, op_value)
when :exists
# TODO add support for false in Searchkick 6
if op_value != true
# TODO raise error in Searchkick 6
Searchkick.warn("Passing a value other than true to exists is not supported")
end
filters << {exists: {field: field}}
else
range_query =
Expand Down
8 changes: 8 additions & 0 deletions test/where_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ def test_exists
{name: "Product B"}
]
assert_search "product", ["Product A"], where: {user_ids: {exists: true}}
# TODO add support for false in Searchkick 6
assert_warns "Passing a value other than true to exists is not supported" do
assert_search "product", ["Product A"], where: {user_ids: {exists: false}}
end
# TODO raise error in Searchkick 6
assert_warns "Passing a value other than true to exists is not supported" do
assert_search "product", ["Product A"], where: {user_ids: {exists: nil}}
end
end

def test_like
Expand Down

0 comments on commit 2eda775

Please sign in to comment.