Commit 07cb870cf051b508b8882289ddbd416a61ee6844
1 parent
0cf957ec
Exists in
master
and in
21 other branches
Fixed bug with range filter and array values - closes #132
Showing
2 changed files
with
10 additions
and
1 deletions
Show diff stats
lib/searchkick/search.rb
... | ... | @@ -262,7 +262,8 @@ module Searchkick |
262 | 262 | else |
263 | 263 | raise "Unknown where operator" |
264 | 264 | end |
265 | - if existing = filters.find { |f| f[:range] && f[:range].keys.include?(field) } | |
265 | + # issue 132 | |
266 | + if existing = filters.find{ |f| f[:range] && f[:range][field] } | |
266 | 267 | existing[:range][field].merge!(range_query) |
267 | 268 | else |
268 | 269 | filters << {range: {field => range_query}} | ... | ... |
test/sql_test.rb
... | ... | @@ -117,6 +117,14 @@ class TestSql < Minitest::Unit::TestCase |
117 | 117 | assert_search "product", ["Product A"], where: {user_ids: {gt: 10, lt: 23.9}} |
118 | 118 | end |
119 | 119 | |
120 | + def test_where_range_array_again | |
121 | + store [ | |
122 | + {name: "Product A", user_ids: [19, 32, 42]}, | |
123 | + {name: "Product B", user_ids: [13, 40, 52]} | |
124 | + ] | |
125 | + assert_search "product", ["Product A"], where: {user_ids: {gt: 26, lt: 36}} | |
126 | + end | |
127 | + | |
120 | 128 | def test_near |
121 | 129 | store [ |
122 | 130 | {name: "San Francisco", latitude: 37.7833, longitude: -122.4167}, | ... | ... |