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

[FEATURE] allow using --like option similar to SQL's LIKE logic #987

Closed
1 of 7 tasks
JoernBerkefeld opened this issue Jun 9, 2023 · 1 comment · Fixed by #1006 or #1023
Closed
1 of 7 tasks

[FEATURE] allow using --like option similar to SQL's LIKE logic #987

JoernBerkefeld opened this issue Jun 9, 2023 · 1 comment · Fixed by #1006 or #1023
Assignees
Labels
enhancement New feature or request; requires increasing the minor version of mcdev. Jira issue-type "Story" PRIORITY used for professional service clients
Milestone

Comments

@JoernBerkefeld
Copy link
Contributor

JoernBerkefeld commented Jun 9, 2023

We often have to update a large subset of metadata, e.g. disable certain users but have issues finding the right ones.

Should be supported by:

  • retrieve
  • execute
  • refresh

out of scope:

  • deploy
  • buildTemplate
  • buildDefinition
  • buildDefinitionBulk

why? because having support in retrieve alone allows us to run deploy and buildX based on the result already.

logic:

  • Filter should support finding strings or check json fields with LIKE % to get partial matches

solution:

  • --like.field "%abc" --> Match a string that ends with abc, similar to LIKE '%abc'
  • --like.field "abc%" --> Match a string that starts with abc, similar to LIKE 'abc%'

https://stackoverflow.com/a/18418386/818732:

function stringLike(testString, search) {
    if (typeof search !== 'string' || this === null) {return false; }
    // Remove special chars
    search = search.replace(new RegExp("([\\.\\\\\\+\\*\\?\\[\\^\\]\\$\\(\\)\\{\\}\\=\\!\\<\\>\\|\\:\\-])", "g"), "\\$1");
    // Replace % and _ with equivalent regex
    search = search.replace(/%/g, '.*').replace(/_/g, '.');
    // Check matches
    return RegExp('^' + search + '$', 'gi').test(testString);
}

const url = 'http://www.mydomain.com/page1.aspx';
console.log(stringLike(url, '%mydomain.com/page_.asp%')); // true

https://www.w3schools.com/sql/sql_like.asp:
The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

There are two wildcards often used in conjunction with the LIKE operator:

The percent sign (%) represents zero, one, or multiple characters
The underscore sign (_) represents one, single character

LIKE Operator Description
--like.Name "a%" Finds any values that start with "a"
--like.key "%a" Finds any values that end with "a"
--like.name "%or%" Finds any values that have "or" in any position
--like.CustomerKey "_r%" Finds any values that have "r" in the second position
--like.Description "a_%" Finds any values that start with "a" and are at least 2 characters in length
--like.customerKey "a__%" Finds any values that start with "a" and are at least 3 characters in length
--like.steps.activities.name "a%o" Finds any values that start with "a" and ends with "o"
@JoernBerkefeld JoernBerkefeld added enhancement New feature or request; requires increasing the minor version of mcdev. Jira issue-type "Story" NEW not yet analyzed new issues get this label labels Jun 9, 2023
@JoernBerkefeld JoernBerkefeld added this to the 5.2.0 milestone Jun 9, 2023
@JoernBerkefeld JoernBerkefeld added PRIORITY used for professional service clients and removed NEW not yet analyzed new issues get this label labels Jun 9, 2023
@JoernBerkefeld JoernBerkefeld changed the title [FEATURE] get keys / copy to deploy based on filter? [FEATURE] instead of using key allow using --filter similar to SQL's LIKE logic Jun 27, 2023
@JoernBerkefeld JoernBerkefeld self-assigned this Jun 27, 2023
JoernBerkefeld added a commit that referenced this issue Jun 27, 2023
@JoernBerkefeld JoernBerkefeld changed the title [FEATURE] instead of using key allow using --filter similar to SQL's LIKE logic [FEATURE] allow using --like option similar to SQL's LIKE logic Jun 27, 2023
@JoernBerkefeld JoernBerkefeld linked a pull request Jun 27, 2023 that will close this issue
6 tasks
@github-actions
Copy link

Closed by #1006.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request; requires increasing the minor version of mcdev. Jira issue-type "Story" PRIORITY used for professional service clients
Projects
None yet
1 participant