Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The "contains" operator does not work as expected for text fields #19576

Open
nbro10 opened this issue Feb 21, 2024 · 4 comments
Open

The "contains" operator does not work as expected for text fields #19576

nbro10 opened this issue Feb 21, 2024 · 4 comments
Assignees
Labels
severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve source: core:content-manager Source is core/content-manager package status: pending reproduction Waiting for free time to reproduce the issue, or more information

Comments

@nbro10
Copy link

nbro10 commented Feb 21, 2024

Bug report

Required System information

  • Node.js version: v20.9.0
  • NPM version: 10.1.0
  • Strapi version: 4.16.2
  • Database: PostgreSQL
  • Operating system: Ubuntu and Mac
  • Is your project Javascript or Typescript: JS

Describe the bug

In the content manager, if I try to add a filter contains to a text field name where the value is old_, I get entries whose name does not contain old_. However, they contain old. So, it seems that the underscore is being ignored here. Clearly, this is not the intended behaviour because underscores should not be ignored and should be treated as any other character.

Steps to reproduce the behavior

  1. Create any content with a text field called name (or whatever)
  2. Create a few entries that have a name with the substring old
  3. Add the filter contains to the content manager where the value is old_ and see that you get entries that do not contain old_ but contain old

Expected behavior

The contains filter works as expected

Screenshots

I cannot share the data with you

Additional context

I cannot update to a Strapi version newer than 4.16.2 until #19532 gets solved.

@kasonde kasonde self-assigned this Feb 23, 2024
@kasonde kasonde added status: can not reproduce Not enough information to reproduce source: core:content-manager Source is core/content-manager package status: pending reproduction Waiting for free time to reproduce the issue, or more information labels Feb 23, 2024
@kasonde kasonde added severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve and removed status: can not reproduce Not enough information to reproduce labels Feb 23, 2024
@strapi strapi deleted a comment from github-actions bot Feb 23, 2024
@kasonde
Copy link
Contributor

kasonde commented Feb 23, 2024

Hi @nbro10
Unfortunately I'm not able to reproduce this issue as you describe it. I've attached a video to this. Please let me know if I'm doing anything wrong and if possible attached a reproduction video of your own.

Content.Manager.-.23.February.2024.mp4

@nbro10
Copy link
Author

nbro10 commented Feb 23, 2024

@kasonde Hi. Thanks for trying to help.

I forgot to mention it. I'm applying the "contains" filter (case insensitive or sensitive) to a relation field. In my case, the relation is called project and it has a name (which is what is shown in the project column I suppose). Can you please try again with this scenario?

(You should also make sure you're using Strapi 4.16.2. Unfortunately, Strapi 4.17 introduced this bug #19532 and I can't update to a newer version until that is solved)

@nbro10
Copy link
Author

nbro10 commented Feb 23, 2024

Actually, I've just tried to filter with the contains operation on the project's name in the project table and it completely returns wrong results, so there might be more than one issue here or it might not be specific to relation fields. For example, with the contains (case sensitive) old_ it returns results that contain old and some underscores but not old followed by _, i.e. old_. For example, it returns a project with this name 2024_Placeholder

The problem also occurs with the starts with operation. It returns projects that start with old although I request that it matches old_

I don't know if this has anything to do it, but my original project was written in v3 and I migrated it recently to v4, using the recommended guides and the official migration scripts.

@xavi-999
Copy link

xavi-999 commented Mar 3, 2024

I've been able to reproduce the bug. It's an SQL issue I already have the fix, can I be assigned to fix this?

03.03.2024_10.58.37_REC.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve source: core:content-manager Source is core/content-manager package status: pending reproduction Waiting for free time to reproduce the issue, or more information
Projects
Status: To be reviewed (Open)
Status: To review
Development

No branches or pull requests

4 participants