Skip to content

filter data using value not substring. - #428

Closed
chauhanparth210 wants to merge 1 commit into
aboutcode-org:developfrom
chauhanparth210:develop
Closed

chauhanparth210 wants to merge 1 commit into
aboutcode-org:developfrom
chauhanparth210:develop

Conversation

@chauhanparth210

Copy link
Copy Markdown

solve : #422

Screenshorts:

  • filter with File Size:
    Screenshot from 2020-03-19 19-41-53

  • filter with File Type:
    Screenshot from 2020-03-19 19-43-27

What I do ?

I remove the last case for filter where filter is using substring rather than value.

@steven-esser steven-esser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please sign off your commits using -s on the git CLI

Signed-off-by: chauhanparth210 <00chauhanparth@gmail.com>
} else {
query.where.$and[columnName] = {
$like: `%${columnSearch}%`
$eq: columnSearch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unfortunately, this will break quite a few filter behaviors. There was a reason why we used a list of values above: Some columns will not filter correctly without a $like.

@chauhanparth210 chauhanparth210 Mar 27, 2020

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

If I back with previous code, in that case only three columns are filtered with $eq else filtered the data using $like in that case it uses sub-string rather then using exact value which we provided as a list on the top of column.

But @MaJuRG sir, my doubt is if we already provide a value on the top of column then why we need of ```$like```` query? if it breaks quite filters so will you provide me a test case where it break a filter behavior?

If it breaks the behavior of filter using $eq then the solution of this issue is to update the list of

const exactFilterColumnNames = ['extension', 'programming_language', 'name'];

and append the list to columns and if filter is break on that case then use $like rather then $eq

Thank you @MaJuRG.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some columns, like license_key, are lists of values at this time. It turns out that filtering with $eq will not work for lists of values, as it expects to match against the entire list as opposed to a single element.

This is not great from a schema standpoint, I will admit, but at this time this is how things work.

@steven-esser

Copy link
Copy Markdown
Contributor

@chauhanparth210 Ping. I will close this soon if you have no more updates.

@steven-esser

Copy link
Copy Markdown
Contributor

Closing due to stagnation.

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.

2 participants