Field attributes containing patched predicates are mishandled
BenjaminMINK opened this issue · 1 comments
Hello,
Expected Behavior
Field attributes containing/ending with any of the custom predicates added by the gem should extract the correct field, and returns the filtered records.
Actual Behavior
Using field attributes that can contains or ends with _max
(and all other custom predicates added by the gem: min, max, avg, sum and count) like bar_abs_max
, bar_abs_min
are mishandled, the gem is extracting as field bar_abs
, so using filter like bar_abs_max_gteq
does not work: it returns all records.
Steps to Reproduce the Problem
- create a model/record field containing/ending with one of the custom predicates (min, max, avg, sum and count)
- request with any filter and other ransack predicates
- check the SQL query & result
Specifications
- Version: 1.7.0
- Ruby version: 3.0.2
- Rails version : 6.1.x
A quick solution would be to give the developer the choice to enable or not these custom predicates
@BenjaminMINK sorry for the delay replying to this one. Have you considered enabling the expressions when filtering?
https://github.com/stas/jsonapi.rb#sorting-using-expressions
Feel free to reopen this if you have questions ;)