Skip to content

feat: add case-insensitive support in advanced Json filtering#4977

Merged
aqrln merged 5 commits intoprisma:mainfrom
lubosmato:main
Feb 17, 2025
Merged

feat: add case-insensitive support in advanced Json filtering#4977
aqrln merged 5 commits intoprisma:mainfrom
lubosmato:main

Conversation

@lubosmato
Copy link
Copy Markdown
Contributor

@lubosmato lubosmato commented Aug 9, 2024

The PR adds case field into Json filtering to allow case-insensitive text filtering with Json fields.

E.g.:

prisma.article.findMany({
  where: {
    title: {
      path: ["en"],
      string_contains: searchText,
      mode: "insensitive",
    },
  }
})

Fixes prisma/prisma#7390

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Aug 9, 2024

CLA assistant check
All committers have signed the CLA.

@lubosmato lubosmato marked this pull request as ready for review August 9, 2024 14:57
@lubosmato lubosmato requested a review from a team as a code owner August 9, 2024 14:57
@lubosmato lubosmato requested review from jkomyno and removed request for a team August 9, 2024 14:57
@lubosmato lubosmato changed the title fix: add case-insensitive support in advanced Json filtering feat: add case-insensitive support in advanced Json filtering Aug 9, 2024
@macrozone
Copy link
Copy Markdown

that would be some awesome to have

Copy link
Copy Markdown
Contributor

@jkomyno jkomyno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! I've left a couple of comments for further iterations and better compatibility with the other database providers.

Comment thread query-engine/connectors/sql-query-connector/src/filter/visitor.rs Outdated
Comment thread query-engine/connectors/sql-query-connector/src/filter/visitor.rs Outdated
@jkomyno jkomyno self-assigned this Aug 12, 2024
@lubosmato lubosmato marked this pull request as draft August 12, 2024 13:26
@lubosmato lubosmato force-pushed the main branch 2 times, most recently from 76913f0 to db9cf81 Compare August 14, 2024 16:38
@lubosmato lubosmato marked this pull request as ready for review August 14, 2024 16:41
@lubosmato
Copy link
Copy Markdown
Contributor Author

lubosmato commented Aug 14, 2024

@jkomyno thank you for review, would you find time for another round?

Also I would like to ask you if you could point me to the right direction. I tried to hook up prisma client with locally built bins/libs to test this feature with prisma generate on an existing project but generated files have no mention of newly added changes (e.g. case field is missing). In dmmf output I can see newly added field case.

I tried to set env vars PRISMA_QUERY_ENGINE_* and PRISMA_SCHEMA_ENGINE_BINARY and run prisma generate. prisma version is showing that correct libs/bins are used but resulting generated types for prisma-client-js generator are not affected.

What needs to be done in order to make prisma-client-js generator generate types with locally built prisma-engines?

@lubosmato
Copy link
Copy Markdown
Contributor Author

Hi @jkomyno, what are the next steps/is there anything else that needs to be done from my end?

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Aug 30, 2024

CodSpeed Performance Report

Merging #4977 will not alter performance

Comparing lubosmato:main (0bfeb01) with main (11f45a2)

Summary

✅ 11 untouched benchmarks

@aqrln
Copy link
Copy Markdown
Member

aqrln commented Aug 30, 2024

Also I would like to ask you if you could point me to the right direction. I tried to hook up prisma client with locally built bins/libs to test this feature with prisma generate on an existing project but generated files have no mention of newly added changes (e.g. case field is missing). In dmmf output I can see newly added field case.

I tried to set env vars PRISMA_QUERY_ENGINE_* and PRISMA_SCHEMA_ENGINE_BINARY and run prisma generate. prisma version is showing that correct libs/bins are used but resulting generated types for prisma-client-js generator are not affected.

What needs to be done in order to make prisma-client-js generator generate types with locally built prisma-engines?

This is slightly annoying to do, sorry for that. Prisma CLI (and generator) doesn't use the query engine to get the DMMF, it uses the WASM module (published as @prisma/prisma-schema-wasm on npm). You can build it locally by running make build-schema-wasm in the engines directory, the built package will be in target/prisma-schema-wasm. Unfortunately there's no convenient way to make CLI use it; what I do is just manually edit https://github.com/prisma/prisma/blob/7955bca6c4e343e452f9138547d42d952ad0c54d/packages/internals/src/wasm.ts#L1 to import this package from the engines directory in the local filesystem and rebuild Prisma.

@lubosmato
Copy link
Copy Markdown
Contributor Author

Hi @jkomyno, what needs to be done to finish this?

1 similar comment
@lubosmato
Copy link
Copy Markdown
Contributor Author

Hi @jkomyno, what needs to be done to finish this?

@lubosmato
Copy link
Copy Markdown
Contributor Author

stale

@aqrln
Copy link
Copy Markdown
Member

aqrln commented Feb 15, 2025

@lubosmato could you please resolve the conflicts? The changes look good to me.

@aqrln aqrln added this to the 6.4.0 milestone Feb 15, 2025
@lubosmato
Copy link
Copy Markdown
Contributor Author

@aqrln thank you for your time! rebased onto main.

@aqrln
Copy link
Copy Markdown
Member

aqrln commented Feb 17, 2025

@lubosmato thanks! Would you mind opening a PR to the docs as well? We can also update them ourselves but then this probably won't make it into the next release and will have to go in 6.5.0.

@aqrln
Copy link
Copy Markdown
Member

aqrln commented Feb 17, 2025

The dev connections team has confirmed they have time to write docs before tomorrow so no worries about that. I'll go ahead and merge this. Thanks a lot for the contribution!

@aqrln aqrln merged commit 7e7c9b8 into prisma:main Feb 17, 2025
@platform-kit
Copy link
Copy Markdown

@jkomyno @aqrln Can you confirm that this shipped in 6.5.0? I am running 6.5.0 right now, but a query with the mode: 'insensitive' argument gives the error:

Unknown argument `mode`. Did you mean `lte`? Available options are marked with ?.

Also, FYI it is unclear from the relevant docs page whether this feature is actually available. It both gives instructions on the argument above and says in the FAQs section that it is unavailable.

https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/working-with-json-fields

@aqrln
Copy link
Copy Markdown
Member

aqrln commented Mar 20, 2025

@platform-kit this was shipped in 6.4.0. Please open an issue with a reproduction if it doesn't work for you.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support case insensitive advanced Json filtering

6 participants