vscode-ibmi icon indicating copy to clipboard operation
vscode-ibmi copied to clipboard

Member object filter allow list of member filters

Open m-tyler opened this issue 2 years ago • 13 comments

Is your feature request related to a problem? Please describe. I often work on a project that can include members with different enough names that a simple member filter does not work. We may have 20 members that are in the same basic name pattern but I only want to select 2 of the twenty. Then I would need to select another few source of another member name pattern but not all that could fit.

For instance, PRP00DRG is the module for a service program for our payroll system. It has other like source companions that I might want to include and there are other programs also named like PRP00* that I don't want. So I would like to be able to filter like this, "PRP00D*;PRP00C*;PRP00ASP;KRN00A*;KRN10A*" so that I bring in only those members that fit the change need I am working on.

Describe the solution you'd like In the member filter if I supply a semi colon (;) I would like this tool to use it a delimter and filter to members of each set included in the object filter.

We use a product from Rocket Aldon call ALdon LM(e). It allows us to check out any source member item and have it appear in a list associated to a project ID. I would like to get as close to this as possible within the constraints of your produce, VS Code and effort to do so.

Alternatives for me is to create a member object filter for each distinct set of sources I need to modify for my change project.

Thanks, Matt

m-tyler avatar Apr 11 '22 16:04 m-tyler

Also, consider adding a member type filter so that I might be able to filter by members in QDDSRC that are DB only members. For instance, KRN*.SQL. This would prevent me from getting DSPF and PRTF entries that might be in another change project I working with at the same time.

m-tyler avatar Apr 11 '22 17:04 m-tyler

Notes to self: neat idea. Would require generating some interesting SQL for when SQL mode is enabled, and same JS when it is disabled.

The important part is to supply a list of member filters like so:

So I would like to be able to filter like this, "PRP00D*;PRP00C*;PRP00ASP;KRN00A*;KRN10A*"

Much like the library list, we can have many delimiters. So while the user is asking for ;, we can also allow for , as well.

In the member filter if I supply a semi colon (;) I would like this tool to use it a delimter and filter to members of each set included in the object filter.

worksofliam avatar Apr 11 '22 19:04 worksofliam

That list could be converted into a REGEX like such PRP00D.{4,}|PRP00C.{4,}|.... You know that object names given for members will only be 10 long and querying the SYSPARTITIONSTAT for those members should produce expected results.

Thanks, Matt

m-tyler avatar Apr 11 '22 19:04 m-tyler

Oh, wait I realized you are not using the system catalogs for a lot of the member operations. But a query against the member DB source you have would still work using REGEXP_LIKE().

m-tyler avatar Apr 11 '22 19:04 m-tyler

New item I ran into today, on a member filter if I don't use 'MEMBER*' pattern the toll will not find my member. That's because of the use of like in the where clause for the member condition.

AND b.system_table_member like 'UTL05LCL' <-- this will not find the member because there is no % character.

m-tyler avatar Apr 14 '22 21:04 m-tyler

So I believe if you change the query for filter listing to this pattern then it will work for a simple selection and for a list.

"SELECT (b.avgrowsize - 12) as MBMXRL, a.iasp_number as MBASP, a.table_name AS MBFILE, b.system_table_member as MBNAME, b.source_type as MBSEU2, b.partition_text as MBMTXT FROM qsys2.systables AS a JOIN qsys2.syspartitionstat AS b ON b.table_schema = a.table_schema AND b.table_name = a.table_name WHERE regexpr_like( a.table_schema , '${library}' ) ${sourceFile !== *ALL ? AND regexpr_like( a.table_name , '${sourceFile}' ) : } ${member ? `AND regexpr_like( b.system_table_member , '${member}'`) : } ORDER BY b.system_table_member "

m-tyler avatar Apr 15 '22 14:04 m-tyler

Where ${library} can be a single value like 'LIB' or a regexp like 'LIB1|LIB2|LIB3' or '^LIB'. Same with the ${file} an ${member} and then its up to the user to know how to pattern regexp to select more.

It also means a need to change the search for the pattern of 'XXX*' to replace it to 'XXX%' and have a new replaced string of '^XXX'.

m-tyler avatar Apr 15 '22 17:04 m-tyler

Just wanted to bump this issue with my 👍

Demoing VS Code for IBM i today and a co-worker quizzed me on how to do this very thing! I said I bet there's an enhancement request already out there for it and sure enough there was.

I'm all for using Regex in the member filters

Wright4i avatar Aug 11 '22 20:08 Wright4i

Whenever a version is released I make mods to the extension to suit my needs.

These are the things I change to meet my needs at the moment.

  1. I disable the checking for the CPYTOIMPF and CPYFRMIMPF as we have our own versions.
  2. I replace the CPYTOIMPF command with our own version.
  3. I change the filter SQL to use REGEXP_LIKE() for the member section. This causes the search over the source file action to stop working unless you fix that.
  4. I remove the replacement of the * with % for a blank as I have my own version of generics using REGEXP_LIKE().
  5. I change the last section of the source file path grep statement to only use * in the member section.

This is a small sample of what my member filter now runs for its SQL.

  SELECT
          (b.avgrowsize - 12) as MBMXRL,
          a.iasp_number as MBASP,
          cast(a.system_table_name as char(10) for bit data) AS MBFILE,
          cast(b.system_table_member as char(10) for bit data) as MBNAME,
          coalesce(cast(b.source_type as varchar(10) for bit data), '') as MBSEU2,
          coalesce(b.partition_text, '') as MBMTXT
        FROM qsys2.systables AS a
          JOIN qsys2.syspartitionstat AS b
            ON b.table_schema = a.table_schema AND
              b.table_name = a.table_name
        WHERE
          cast(a.system_table_schema as char(10) for bit data) = 'library' 
          AND cast(a.system_table_name as char(10) for bit data) = 'QRPGSRC'
          AND regexp_like( b.system_table_member , '^JOB_DATE_V |^KRN02AFN09 |^KRN02ARG |^PRPEHTV5 |^PRP00AFN24 |^PRP00AFN25')

This does work but presents a problem because I have to modify the filter to include additional member references when the project changes. And I have to constantly look in the source files to see if a member is in it.

Frankly, I would like to see the tool evolve in such a way that as the customer I get to write a query that produces the results, following the required data items to return.

I have been slowly working on a query that queries from our company's CMS product (Rocket Aldon) to get a list of items checked out for a project. I do intend to use this query as the replacement for the packaged query. A downside is that some of the right-click commands will probably stop working but I don't need them most of the time.

m-tyler avatar Aug 11 '22 20:08 m-tyler

@m-tyler wow, you're really putting in a lot of work.

I am open to the SQL regex stuff, but we'd also have to make it work when SQL is disabled (running the regex against the list locally).

I personally think you should take that functionality into a PR. I'm sure @chrjorgensen would love to see it too.

worksofliam avatar Aug 12 '22 03:08 worksofliam

Great idea - regexp provides a lot of flexibility when searching in text (and I tend to use REGEXP_LIKE more than LIKE in SQL).

Just some comments:

  • as @worksofliam says, it should also work when SQL is not activated
  • it should be an option to use regexp - not everyone wants to learn/use this advanced pattern matching, and the current generic pattern is known to all IBM i developers
  • the idea could be enhanced to allow listing members across libraries and/or files - like the filter method in RDi - and thus provide a full list of source members for a project. This could be done by making the filter into an array of filters...?

@m-tyler A PR would be great!

chrjorgensen avatar Aug 12 '22 09:08 chrjorgensen

It's not that much work when its just a scan and a replace, I do have to watch and not update the extension when I don't have the time and/or the changes don't affect me. I forgot to mention one other modification I now have to make. For some reason I don't understand, the packaged member filter SQL query uses rtrim(cast(b.system_table_member as char(10) for bit data)). REGEXP_* functions can't work with data converted into for bit data and with code page 37 converting to for bit data has no effect I know about because all members are stored in upper case letters.

As far as a PR, I have to admit I am too new to the git processes, etc. so I will defer this to someone else.

m-tyler avatar Aug 12 '22 19:08 m-tyler

I wrote a couple of SQL table functions that do what I want to solve this problem. I modified the distributed extension to have them run over the delivered code if enableSQL is true.

I am willing to share these if there is interest. They contain code specific to my environment so I might need to modify them for more common use.

m-tyler avatar Oct 05 '22 14:10 m-tyler