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

Add regex support to Search.dataSets #2443

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

JWaters02
Copy link
Member

@JWaters02 JWaters02 commented Feb 22, 2025

What It Does

Closes #2432

Implements the regex option on the data sets search:

  • On mainframe search, it queries on ?research
  • On local search, it just uses normal regex matchAll

In #2432 I pondered about implementation of this option without causing a breaking change:

There are two options:

  1. Copy what searchJobs has, which means to make searchString into an optional parameter, then add a new optional parameter alongside it called searchRegex
  2. Keep searchString a required option, but add an optional boolean called isRegex or similar, which when true would call the API with the research query instead of the search one.

I like option 1 more because it would be a standard implementation between jobs and datasets. However, unfortunately this would cause a breaking change (as searchString would have to be made optional), which I would prefer to avoid (to allow this feature to come sooner), so therefore option 2 would have to do. But please let me know what your thoughts on that are.

No one let me know what their thoughts on that were, but I think it is pretty straight forward that option 2 is the right way to go for v3. So what I implemented was a new, optional --regex option (please let me know if the name should be changed) that when specified sets the searchString into a regex one. If reasonable, I could open an issue with the code changes required to switch to option 1 that would go in as v4 breaking change.

Obviously, one thing that needs to be taken into account, is that cases is not sensitive by default, which if combined with a regex string, may produce unintended effects - but that is up to the user (and the docs to point it out). For example, this regular expression specifies only upper case characters, but since the --case-sensitive option is not passed, it will match on the lower case characters anyway:

image

I had to refactor the logic in Search.dataSets and Search.searchLocal functions to take into account that the matched string length, for the text highlighting in output, would not be the same as the search string length for a regex search string.

Here are some random examples of using it:

image

How to Test

Run zowe files search data-sets <pattern> <search string> --regex and mess around with it!

Review Checklist
I certify that I have:

Additional Comments

This will require a PR on the docs-site so go in alongside it.

@JWaters02 JWaters02 force-pushed the feat/ds-search-regex-2 branch from 578629d to eb16bee Compare February 22, 2025 20:55
Copy link

codecov bot commented Feb 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.51%. Comparing base (b91b989) to head (dba1463).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #2443    +/-   ##
========================================
  Coverage   91.50%   91.51%            
========================================
  Files         641      641            
  Lines       18376    18390    +14     
  Branches     3872     3990   +118     
========================================
+ Hits        16815    16829    +14     
  Misses       1559     1559            
  Partials        2        2            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JWaters02
Copy link
Member Author

I couldn't figure out how to run the system tests for the Search.system.test.ts file, and docs isn't clear enough on how to set it up, so I got really confused and gave up. So that file is currently untouched. Any help on how to get it working would be muchly appreciated.

@JWaters02
Copy link
Member Author

The build CI is failing because the snapshot has changed, how do I commit that?

Signed-off-by: JWaters02 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Add regex support to Search.dataSets
1 participant