-
Notifications
You must be signed in to change notification settings - Fork 784
Add documentation for the LPAD and RPAD OQL functions #11190
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
Open
passalaqua
wants to merge
2
commits into
mendix:development
Choose a base branch
from
passalaqua:dat/feature/pad-functions
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+106
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -692,10 +692,12 @@ These are the currently supported functions: | |
| * LENGTH | ||
| * LOCATE | ||
| * LOWER | ||
| * LPAD | ||
| * RANGEBEGIN | ||
| * RANGEEND | ||
| * REPLACE | ||
| * ROUND | ||
| * RPAD | ||
| * UPPER | ||
|
|
||
| ### CAST{#cast} | ||
|
|
@@ -1329,6 +1331,57 @@ SELECT * FROM Sales.Customer WHERE LOWER(LastName) = 'doe' | |
| This query can no longer take advantage of an index for `LastName` for comparison, resulting in a performance decrease. | ||
| {{% /alert %}} | ||
|
|
||
| ### LPAD {#lpad-function} | ||
|
|
||
| #### Description | ||
|
|
||
| Pads a string on the left side with a specified character to reach a target length. | ||
|
|
||
| {{% alert color="info" %}} | ||
| This function was introduced in Mendix version 11.12.0. | ||
| {{% /alert %}} | ||
|
|
||
| #### Syntax | ||
|
|
||
| ```sql | ||
| LPAD ( expression , length_expression [, pad_expression ] ) | ||
| ``` | ||
|
|
||
| #### expression | ||
|
|
||
| `expression` specifies the expression of type `string` to pad. | ||
|
|
||
| #### length_expression | ||
|
|
||
| `length_expression` specifies, as an `integer`, the length of the resulting string. | ||
|
|
||
| {{% alert color="info" %}} | ||
| If `length_expression` is smaller than the length of `expression`, this function truncates it. This behavior is database specific. | ||
| {{% /alert %}} | ||
|
|
||
| #### pad_expression | ||
|
|
||
| `pad_expression` is an optional parameter that specifies the character or string to pad with. If not specified, the space character is used. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's visualize the character:
|
||
|
|
||
| #### Examples | ||
|
|
||
| ```sql | ||
| SELECT LPAD('hello', 10) AS padded FROM Sales.Order | ||
| ``` | ||
|
|
||
| | padded | | ||
| |:-----------| | ||
| | hello | | ||
|
|
||
|
|
||
| ```sql | ||
| SELECT LPAD('hello', 10, 'x') AS padded FROM Sales.Order | ||
| ``` | ||
|
|
||
| | padded | | ||
| |:-----------| | ||
| | xxxxxhello | | ||
|
|
||
| ### Ranges in Datasets | ||
|
|
||
| {{% alert color="info" %}} | ||
|
|
@@ -1507,6 +1560,57 @@ SELECT ROUND((Price : 7), 2) as RoundedPrice, Price : 7 FROM Sales.Order | |
| | 0.33 | 3.33333333 | | ||
| | 1.17 | 1.17142857 | | ||
|
|
||
| ### RPAD {#rpad-function} | ||
|
|
||
| #### Description | ||
|
|
||
| Pads a string on the right side with a specified character to reach a target length. | ||
|
|
||
| {{% alert color="info" %}} | ||
| This function was introduced in Mendix version 11.12.0. | ||
| {{% /alert %}} | ||
|
|
||
| #### Syntax | ||
|
|
||
| ```sql | ||
| RPAD ( expression , length_expression [, pad_expression ] ) | ||
| ``` | ||
|
|
||
| #### expression | ||
|
|
||
| `expression` specifies the expression of type `string` to pad. | ||
|
|
||
| #### length_expression | ||
|
|
||
| `length_expression` specifies, as an `integer`, the length of the resulting string. | ||
|
|
||
| {{% alert color="info" %}} | ||
| If `length_expression` is smaller than the length of `expression`, this function truncates it. | ||
| {{% /alert %}} | ||
|
|
||
| #### pad_expression | ||
|
|
||
| `pad_expression` is an optional parameter that specifies the character or string to pad with. If not specified, the space character is used. | ||
|
|
||
| #### Examples | ||
|
|
||
| ```sql | ||
| SELECT RPAD('hello', 10) AS padded FROM Sales.Order | ||
| ``` | ||
|
|
||
| | padded | | ||
| |:-----------| | ||
| | hello | | ||
|
|
||
|
|
||
| ```sql | ||
| SELECT RPAD('hello', 10, 'x') AS padded FROM Sales.Order | ||
| ``` | ||
|
|
||
| | padded | | ||
| |:-----------| | ||
| | helloxxxxx | | ||
|
|
||
| ### SUBSTRING{#substring-function} | ||
|
|
||
| #### Description | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would propose a different wording: