Add views filter support

Created on 31 January 2023, over 2 years ago

Problem/Motivation

Currently, it is not possible to use Views filters on JSON fields. It would be great to have a way to have filter support-- at least for text-based JSON fields (then perhaps the standard views StringFilter could be used).

The question is how would support for native JSON fields be implemented?

โœจ Feature request
Status

Active

Version

1.0

Component

Code

Created by

๐Ÿ‡ฏ๐Ÿ‡ตJapan ptmkenny

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @ptmkenny
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sharique

    For me it will be useful if we can export certain attribute in json as exposed filter.

  • First commit to issue fork.
  • Merge request !42Resolve #3337960 "Add views filter" โ†’ (Open) created by sokru
  • Pipeline finished with Success
    19 days ago
    Total: 279s
    #500036
  • ๐Ÿ‡ซ๐Ÿ‡ฎFinland sokru

    With help of AI, I made proof-of-concept for this, works only with MariaDB/MySQL.
    Would require more work for sqlite and postgresql.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Charlie ChX Negyesi ๐ŸCanada

    Thanks for the PoC.

    I left you a couple nits in Slack but I wanted to note: as far as I can tell user supplied jsonpath goes into the query unescaped, that looks like
    a problem to me.

    Also, , this is what backend overridable services were invented for. I would put the mysql specific logic into one such making eventual postgresql and sqlite implentations seemlessly integrate.

    services:
      json_field.query:
         class: this could be an abstract class
        tags:
          - { name: backend_overridable }
      mysql.json_field.query:
         class: Some\Helper\Containing\The\MySQL\Logic
    

    Check the views.date_sql service and friends for an example.

Production build 0.71.5 2024