I'm a little confused as to what's going on, but upgrading from 0.8.3 to 0.9 broke some filters I have in place. e.g.:
VERIFY_RADIUS_FILTER = ->(value, context) {
return NoLimit.new unless context[:current_location].present?
value
}
FILTER_RADIUS_FROM_LOCATION = ->(records, value, options) {
location = options.dig(:context, :current_location)
limit = Array(value).first
return records unless location.present? && limit.present?
records.near(location, Float(limit))
}
filter :radius, default: 100.0,
verify: VERIFY_RADIUS_FILTER,
apply: FILTER_RADIUS_FROM_LOCATION
I think this commit my be the culprit? cerebris/jsonapi-resources@3a691b2
From what I can tell, this results in Resource#verify_resource being called twice. For a custom filter, at least (which is what I've got), that means the raw value gets doubly-nested in an array: https://github.com/cerebris/jsonapi-resources/blob/19f4d7b59f92b05fa28c4f925391cf5998123308/lib/jsonapi/resource.rb#L753
Instead I wonder if that line should be something like:
filter_values += raw.is_a?(String) ? CSV.parse_line(raw) : Array(raw)
To make sure we don't wrap an array?
/cc @hidde-jan
I'm a little confused as to what's going on, but upgrading from 0.8.3 to 0.9 broke some filters I have in place. e.g.:
I think this commit my be the culprit? cerebris/jsonapi-resources@3a691b2
From what I can tell, this results in
Resource#verify_resourcebeing called twice. For a custom filter, at least (which is what I've got), that means therawvalue gets doubly-nested in an array: https://github.com/cerebris/jsonapi-resources/blob/19f4d7b59f92b05fa28c4f925391cf5998123308/lib/jsonapi/resource.rb#L753Instead I wonder if that line should be something like:
To make sure we don't wrap an array?
/cc @hidde-jan