diff --git a/CHANGELOG.md b/CHANGELOG.md index 52bec3a4..0c9a7875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index cbbcc9c6..62b3c99b 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -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 = diff --git a/test/where_test.rb b/test/where_test.rb index fae97ae2..991c4908 100644 --- a/test/where_test.rb +++ b/test/where_test.rb @@ -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