Support for JSON field selectors (data->"$.a.b.c")
- Dominant language
- Go
- Stars
- 786
- Forks
- 61
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 2
Description
MySQL allows querying a property from a JSON field using [special syntax](https://dev.mysql.com/doc/refman/8.4/en/json.html), for example, like so `SELECT col->"$.mascot" FROM qtest`. In our system, we use normal columns to narrow down results to just a few hundreds rows, but then apply a few JSON filters to further filter and sort records based on the values in the JSON fields. The value stored in JSON is dynamic, and it's not feasible to extract it into a column.
The query looks something like this:
```
SELECT * FROM records WHERE scope = ? AND data->'$.r_12345' != 0 ORDER BY data->'$.r_12345' ASC
```
I can add a filter by JSON field using `rel.FilterFragment` API, but unfortunately, there is nothing similar for `ORDER BY` portion.
What would be the best way to implement it, and is there a workaround? For example, adding support for `col->"..."` to a field escape function or maybe just adding support for `rel.OrderFragment`?
Contributor guide
Assessment
This issue has not been assessed yet.