payloadcms / payload

The best way to build a modern backend + admin UI. No black magic, all TypeScript, and fully open-source, Payload is both an app framework and a headless CMS.
https://payloadcms.com
MIT License
21k stars 1.26k forks source link

db-postgres: `is like` filter condition does case-insensitive text search and the result is equivalent to `contains` filter #6898

Open ikenox opened 5 days ago

ikenox commented 5 days ago

Link to reproduction

No response

Describe the Bug

Both of is like and contains filter does case-insensitive search by postgres ILIKE operator, and the issued SQL and search results are idential. I guess that is like should do case-sensitive search by postgres LIKE operator.

To Reproduce

You can reproduce the problem by _community app:

Filter by is like condition

image

SQL

select "posts"."id", "posts"."text", "posts"."title", "posts"."updated_at", "posts"."created_at", "posts__rels"."data" as "_rels" from "posts" left join lateral (select coalesce(json_agg(json_build_array("posts__rels"."order", "posts__rels"."path", "posts__rels"."media_id") order by "posts__rels"."order" asc), '[]'::json) as "data" from (select * from "posts_rels" "posts__rels" where "posts__rels"."parent_id" = "posts"."id" order by "posts__rels"."order" asc) "posts__rels") "posts__rels" on true where "posts"."text" ilike $1 order by "posts"."title" asc limit $2

Filter by contains condition

image

SQL

select "posts"."id", "posts"."text", "posts"."title", "posts"."updated_at", "posts"."created_at", "posts__rels"."data" as "_rels" from "posts" left join lateral (select coalesce(json_agg(json_build_array("posts__rels"."order", "posts__rels"."path", "posts__rels"."media_id") order by "posts__rels"."order" asc), '[]'::json) as "data" from (select * from "posts_rels" "posts__rels" where "posts__rels"."parent_id" = "posts"."id" order by "posts__rels"."order" asc) "posts__rels") "posts__rels" on true where "posts"."text" ilike $1 order by "posts"."title" asc limit $2

Payload Version

2.22.0 (db-postgres: 0.8.5)

Adapters and Plugins

No response