From 53bb08d82c9e60f8f91911daf17f5fcf23ff0510 Mon Sep 17 00:00:00 2001 From: flamber <1447303+flamber@users.noreply.github.com> Date: Thu, 16 Apr 2020 18:46:24 +0200 Subject: [PATCH] Fix expression 'replace' helper text (#12317) * Fix expression 'replace' helper text * Prettier * Kyle correctness :-) Co-Authored-By: Kyle Doherty <kdoh@users.noreply.github.com> Co-authored-by: Kyle Doherty <kdoh@users.noreply.github.com> --- docs/users-guide/expressions.md | 4 +-- .../lib/expressions/helper_text_strings.js | 26 +++++-------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/docs/users-guide/expressions.md b/docs/users-guide/expressions.md index 60e05948b58..5db02368f94 100644 --- a/docs/users-guide/expressions.md +++ b/docs/users-guide/expressions.md @@ -76,7 +76,7 @@ This would return rows where `Created At` is between January 1, 2020 and March 3 | Percentile | `percentile(column, percentile-value)` | Returns the value of the column at the percentile value. | `percentile([Score], 0.9)` | | Power | `power(number, exponent)` | Raises a number to the power of the exponent value. | `power([Length], 2)` | | Regex extract | `regexextract(text, regular_expression)` | Extracts matching substrings according to a regular expression. | `regexextract( [Address], "[0-9]+" )` | -| Replace | `replace(text, position, length, new_text)` | Replaces a part of the input text with new text. | `replace( [Order ID], 8, 3, [Updated Part of ID] )` | +| Replace | `replace(text, find, replace)` | Replaces a part of the input text with new text. | `replace( [Title], "Enormous", "Gigantic" )` | | Round | `round(number)` | Rounds a decimal number either up or down to the nearest integer value. | `round([Temperature])` | | Right trim | `rtrim(text)` | Removes trailing whitespace from a string of text. | `rtrim( [Comment] )` | | Share | `share(condition)` | Returns the percent of rows in the data that match the condition, as a decimal. | `share( [Source] = "Goolge" )` | @@ -94,7 +94,7 @@ This would return rows where `Created At` is between January 1, 2020 and March 3 Certain database types don't support some of the above functions: -MySQL +MySQL and SQL Server - median - percentile diff --git a/frontend/src/metabase/lib/expressions/helper_text_strings.js b/frontend/src/metabase/lib/expressions/helper_text_strings.js index 34cd35972bd..fb001103028 100644 --- a/frontend/src/metabase/lib/expressions/helper_text_strings.js +++ b/frontend/src/metabase/lib/expressions/helper_text_strings.js @@ -235,35 +235,21 @@ const helperTextStrings = [ }, { name: "replace", - structure: - "replace(" + - t`text` + - ", " + - t`position` + - ", " + - t`length` + - ", " + - t`new_text` + - ")", + structure: "replace(" + t`text` + ", " + t`find` + ", " + t`replace` + ")", description: t`Replaces a part of the input text with new text.`, - example: - "replace([" + t`Order ID` + "] , 8, 3, [" + t`Updated Part of ID` + "] )", + example: "replace([" + t`Title` + '] , "Enormous", "Gigantic")', args: [ { name: t`text`, description: t`The text that will be modified.`, }, { - name: t`position`, - description: t`The position where the replacing will start.`, - }, - { - name: t`length`, - description: t`The number of characters to replace.`, + name: t`find`, + description: t`The text to find.`, }, { - name: t`new_text`, - description: t`The text to use in the replacement.`, + name: t`replace`, + description: t`The text to use as the replacement.`, }, ], }, -- GitLab