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

Search in a listing doesn't find values in select field with multiple values #7905

Open
ofourny opened this issue Apr 26, 2021 · 2 comments
Open
Labels
stale Stale issues & PRs flagged for closing

Comments

@ofourny
Copy link

ofourny commented Apr 26, 2021

Search in a listing doesn't find values in select field with multiple values

Details

Question Answer
Relevant Bolt Version 4.1.13
Install type Composer install
BC Break yes/no
PHP version 7.4.15
Web server Apache

Reproduction

Bug summary

Search on a select field with multiple: true doesn't find results in multi valued content.

Specifics

I setup a content type named "events" with a field "eventtypes" with multiple: true, if I select several values in my field "eventtypes", the search don't show the results containing my value if it is not in the first position.

The "eventtypes" field I'm setting for my "event" content type:
eventtype

I should have two results (two events containing the "festival" value):
issue

But I only get one :
eventtype2

Query produced by the search :

SELECT content FROM Bolt\Entity\Content content LEFT JOIN content.fields fields_eventtype LEFT JOIN fields_eventtype.translations translations_eventtype WHERE content.contentType = :ct0 AND ((JSON_EXTRACT(translations_eventtype.value, '$[0]') LIKE :eventtype_1 AND fields_eventtype.parent IS NULL AND fields_eventtype.name = :field_eventtype) AND content.status = :status_1) ORDER BY content.publishedAt DESC
ct0: spectacles
eventtype_1: %festivals%
status_1: published
field_eventtype: eventtype

Steps to reproduce

  1. Set up a content type with multiple: true and several values in it.
    eventtype: type: select values: [ none, concerts, festivals, spectacles, sport] group: Contenu multiple: true
  2. Create two content of your content type, one with only the value you want to find (example : festivals) another with multiple values (example: concerts, festivals, sport)
  3. Setup a search in your listing
    {% setcontent results = 'spectacles' where { 'eventtype' : '%festivals%' } printquery %}`

Expected result

Both contents containing the value "festivals"

Actual result

Only contents containing "festivals" selected alone, of in first position.

@ofourny
Copy link
Author

ofourny commented Apr 26, 2021

Reason of the behavior

JSON_EXTRACT(translations_eventtype.value, '$[0]') expect the match/result will be in first position while it might not be when the value is an array.

instead it should be something like in the screenshot below this for it to work, but JSON_UNQUOTE and JSON_SEARCH seems to not be compatible with doctrine :
image

Might be hard to come up with a simple fix as wrapJsonFunction() in src/Doctrine/JsonHelper.php is a generic function used in several places.

@stale
Copy link

stale bot commented Jul 30, 2021

This issue has been automatically marked as stale because it has not had recent activity. Maybe this issue has been fixed in a recent release, or perhaps it is not affecting a lot of people?
It will be closed if no further activity occurs, because we like to keep the issue queue concise and actual.
If you think this issue is still relevant, please let us know. Especially if you’d like to help resolve the issue, either by helping us pinpointing the cause of a bug, or in implementing a fix or new feature.

@stale stale bot added the stale Stale issues & PRs flagged for closing label Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issues & PRs flagged for closing
Projects
None yet
Development

No branches or pull requests

1 participant