patricklindsay / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
http://wicegrid.herokuapp.com/
MIT License
33 stars 29 forks source link

JSON column support #54

Open MrShemek opened 5 years ago

MrShemek commented 5 years ago

Hi guys,

Are you going to add a JSON column support to wice_grid? Currently, I can display the values from JSON column but I cannot sort by them.

In MySQL, it is possible to sort by JSON value in two ways:

SELECT id, JSON_EXTRACT(attributes, '$.attribute') AS attribute FROM table ORDER BY attribute ASC
SELECT id, attributes->>'$.attribute' AS attribute FROM table ORDER BY attribute ASC

The problem is that wice_grid does not accept a string with dot as attribute value. It assumes that if the dot was passed, then someone tries to send both table and column name as attribute (which is incorrect).

Thanks, Shemek

PS. if the answer is "no", then please do not close this issue. I will check changes required for JSON support and try to add them.