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

Filter CSV Fields _in & _nin don't work when multiple values present #22176

Open
w0kyj opened this issue Apr 11, 2024 · 1 comment
Open

Filter CSV Fields _in & _nin don't work when multiple values present #22176

w0kyj opened this issue Apr 11, 2024 · 1 comment
Assignees

Comments

@w0kyj
Copy link
Member

w0kyj commented Apr 11, 2024

Describe the Bug

Data Studio filters allow for Is one of(_in) and Is not one of(_nin) operations, however, they don't work when multiple values present in the field. Since it is an available option for the operations of this field type, the results should include any items with matching values in the csv list.

Existing/Related Issues:
There are some related tickets, but they were closed as fixed with the recent _contains PR or closed due to overlap with JSON filtering.
#12496
#11309

OPTIONAL:
It would also be great to provide selection of available values(at least the preset ones) like the current dropdown fields do.

Known workaround is the use multiple Contains(_contains) and Doesn't contain(_ncontains) with logical AND/OR, but is hard for Data Studio users to set up and use. Noted workarounds in other tickets:
#12496 (comment)
#11309 (comment)

To Reproduce

Create a collection with a tags csv data type field eg keywords
Add a few records to the collection

  • record with a single tag value eg content
  • record with multiple values eg data content OR content data
    Add a filter to the tags field in the collection layout
  • eg keywords Is one of content

Before filter and showing the valid options:
Screenshot 2024-04-11 at 10 40 46 AM

Filter Example with missing records:

  • Only shows one of three available records that include content in the tags
Screenshot 2024-04-11 at 11 19 42 AM

Directus Version

v10.10.5

Hosting Strategy

Directus Cloud

@hanneskuettner
Copy link
Contributor

As correctly pointed out in #11309 (comment) the CSV fields are stored as simple strings in the DB and filter operations are plain string operations. In this context the _in and _nin operators check for the presence of the full string value in an array of possible values and is expected not to work in the desired way for this issue.

Effectively the "is one of" operation for a CSV value should read more as a "contains one of", since we want to check the overlap between the CSV values and the filter values.

Since on the DB side of things they are strings only and have no notion of being separate items, there is no nice ways of filtering the records that works reliably and efficiently.

As such we should think about maybe disabling the _in and _nin filters for CSV fields altogether and solely rely on a combination of and/or and contains in order to avoid confusion. I would appreciate input on that decision.

In the particular case of having tags, the cleaner solution from a DB standpoint would be to have a separate tags collection and utilize a M2M relation that can be properly filtered. For example with the M2M Tags Interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🙅 Blocked
Development

No branches or pull requests

3 participants