Skip to content

Preview feature feedback: Filtering Json fields (filterJson) #7135

Closed
prisma/prisma-engines
#2958

Description

@matthewmueller

Please share your feedback about the filterJson functionality released in v2.23.0 in this issue.

  • If you encounter a bug, please open a bug report in this repo.
  • If the feature is working well for you, please share this in a comment below or leave a 👍 on this issue.

If you have any questions, don't hesitate to ask them in the #prisma-client channel in the Prisma Slack.

Activity

  1. matthewmueller commented on May 18, 2021

    @matthewmueller
    ContributorAuthor

    For Postgres users: you should always use path: string[] syntax. Right now we support path: string, but this will be disabled in the future to avoid the expectation that Postgres supports dot notation.

    Postgres doesn't support:

    { 
      "path": "key.inner.most"
    }
    

    Instead it supports:

    { 
      "path": ["key", "inner", "most"]
    }
    

    Here's an issue: #7136

    For MySQL Users: MySQL does support dot notation:

    { 
      path: "$.key.inner.most" 
    }
    

    So the string support will remain for MySQL.

    Why? For maximum query flexibility, we pass the query paths directly into the database engines. The tradeoff is that the syntaxes are different.

  2. andrewtran1995 commented on Jun 1, 2021

    @andrewtran1995

    Loving this feature so far! ❤️ The Prisma client documentation specifies that filtering on an object key inside of an array is only currently supported for the MySQL database connector.

    Are there plans to expand this to other connectors as well, particularly PostgreSQL?

  3. Pehesi97 commented on Jun 1, 2021

    @Pehesi97

    This feature is missing case insensitivity support (at least for PostgreSQL, since I used to specify the mode field to enable it for other field types)

  4. wyozi commented on Jun 2, 2021

    @wyozi

    Great feature. Supporting JSON object containment check (@> in Postgres) would allow me to stop relying on custom SQL for search query filtering. My usecase is querying rows where metadata (a shallow JSONB object with arbitrary keys and non-object values) contains specific subset of key-value pairs.

  5. added
    topic: Json
    on Jun 4, 2021
  6. janpio commented on Jun 4, 2021

    @janpio
    Contributor

    (Make sure there is an issue for this @wyozi - sounds like a good feature request)

  7. changed the title [-]Preview feature feedback: Filtering JSON fields[/-] [+]Preview feature feedback: Filtering JSON fields (`filterJson`)[/+] on Jun 5, 2021
  8. tre-dev commented on Jun 15, 2021

    @tre-dev

    Similar to @andrewtran1995, it would be great if I'd be able to filter JSON fields within a JSON[] using PostgreSQL.

  9. added this to the 2.31.0 / 3.0.x milestone on Aug 19, 2021
  10. removed this from the 2.31.0 / 3.0.x milestone on May 25, 2022
  11. added
    tech/engines
    on May 25, 2022
  12. songkeys commented on Jun 15, 2022

    @songkeys

    Hi. I saw this issue was closed because filterJson is not in preview anymore. But has the feature request "case insensitivity" been taken into consideration?

  13. cprieto commented on Jun 15, 2022

    @cprieto

    Sorry @songkeys, this issue must be opened for feedback in the feature preview and I closed it by accident, I think it will be better (for tracking) if once the release is out a new ticket is created with the case insensitivity in JSON filtering as a feature (it is easier for us to plan and track instead of having just a huge list of comments in a single ticket). Would that work for you?

  14. songkeys commented on Jun 15, 2022

    @songkeys

    @cprieto Yes! Definitely sounds great. Thank you so much for the work. 👍🏻

  15. added this to the 4.0.x milestone on Jun 15, 2022
  16. semurgx commented on Jul 1, 2022

    @semurgx

    It would be great, if Prisma would support Postgres's @> operator for JSON filtering.

  17. muhammad-Osman commented on Sep 5, 2022

    @muhammad-Osman
    "questions_and_answers": [
                {
                    "assessment_id": "3440fca4-4652-4d50-a786-afb824ac9a73",
                    "question_id": "048ee0b7-2dd0-45ec-b7ba-308e5e87e0f7",
                    "answer": {
                        "ans": "yes"
                    },
                    "label": "QR1"
                },
         ]
    

    i want to filter JSON on the base of label but once i give path under where condition it is giving me error

  18. ajhollowayvrm commented on Nov 2, 2022

    @ajhollowayvrm

    Another bump on this for support Postgres JSON filtering and even other JSONB operators like JSONB_Insert.

  19. rohanrajpal commented on Nov 25, 2022

    @rohanrajpal

    Similar to @andrewtran1995, it would be great if I'd be able to filter JSON fields within a JSON[] using PostgreSQL.

    I was also figuring out a way to do this, were you able to figure it out or is it yet to be implemented?

  20. changed the title [-]Preview feature feedback: Filtering JSON fields (`filterJson`)[/-] [+]Preview feature feedback: Filtering `Json` fields (`filterJson`)[/+] on Jun 12, 2023
  21. janpio commented on Jun 12, 2023

    @janpio
    Contributor

    Filtering on a Json field has been GA for a while now since 4.0.0, Jun 28, 2022: https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filter-on-a-json-field

    If you still have some cases that are not covered, please open a new issue. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech/enginestopic: Jsontopic: filterJsontopic: previewFeatures

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions