Skip to content

Commit

Permalink
Validate both in and notin the same way
Browse files Browse the repository at this point in the history
This commit fixes the following error

Model.search_for("id !^ (2,3)") fails with
ScopedSearch::QueryNotSupported: Value '2,3' is not valid for field 'id'

It does it by splitting value for both in and not in
  • Loading branch information
parthaa committed Oct 23, 2023
1 parent 504a849 commit 2520931
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/scoped_search/query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def to_single_field_sql(builder, definition, &block)
raise ScopedSearch::QueryNotSupported, "Field '#{lhs.value}' not recognized for searching!" unless field

# see if the value passes user defined validation
if operator == :in
if [:in, :notin].include?(operator)
rhs.value.split(',').each { |v| validate_value(field, v) }
else
validate_value(field, rhs.value)
Expand Down

0 comments on commit 2520931

Please sign in to comment.