-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add trim, ltrim, rtrim functions (#512)
- Loading branch information
Showing
7 changed files
with
452 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
-- setup: | ||
CREATE TABLE test( | ||
a TEXT | ||
); | ||
|
||
INSERT INTO test (a) VALUES (" hello "), ("!hello!"), (" !hello! "); | ||
|
||
-- test: LTRIM TEXT default | ||
SELECT strings.LTRIM(a) FROM test; | ||
/* result: | ||
{ | ||
"LTRIM(a)": "hello " | ||
} | ||
{ | ||
"LTRIM(a)": "!hello!" | ||
} | ||
{ | ||
"LTRIM(a)": "!hello! " | ||
} | ||
*/ | ||
|
||
|
||
-- test: LTRIM TEXT with param | ||
SELECT strings.LTRIM(a, "!") FROM test; | ||
/* result: | ||
{ | ||
"LTRIM(a, \"!\")": " hello " | ||
} | ||
{ | ||
"LTRIM(a, \"!\")": "hello!" | ||
} | ||
{ | ||
"LTRIM(a, \"!\")": " !hello! " | ||
} | ||
*/ | ||
|
||
-- test: LTRIM TEXT with multiple char params | ||
SELECT strings.LTRIM(a, " !") FROM test; | ||
/* result: | ||
{ | ||
"LTRIM(a, \" !\")": "hello " | ||
} | ||
{ | ||
"LTRIM(a, \" !\")": "hello!" | ||
} | ||
{ | ||
"LTRIM(a, \" !\")": "hello! " | ||
} | ||
*/ | ||
|
||
|
||
-- test: LTRIM TEXT with multiple char params | ||
SELECT strings.LTRIM(a, "hel !") FROM test; | ||
/* result: | ||
{ | ||
"LTRIM(a, \"hel !\")": "o " | ||
} | ||
{ | ||
"LTRIM(a, \"hel !\")": "o!" | ||
} | ||
{ | ||
"LTRIM(a, \"hel !\")": "o! " | ||
} | ||
*/ | ||
|
||
|
||
-- test: LTRIM BOOL | ||
SELECT strings.LTRIM(true); | ||
/* result: | ||
{ | ||
"LTRIM(true)": NULL | ||
} | ||
*/ | ||
|
||
-- test: LTRIM INT | ||
SELECT strings.LTRIM(42); | ||
/* result: | ||
{ | ||
"LTRIM(42)": NULL | ||
} | ||
*/ | ||
|
||
-- test: LTRIM DOUBLE | ||
SELECT strings.LTRIM(42.42); | ||
/* result: | ||
{ | ||
"LTRIM(42.42)": NULL | ||
} | ||
*/ | ||
|
||
-- test: LTRIM ARRAY | ||
SELECT strings.LTRIM([1, 2]); | ||
/* result: | ||
{ | ||
"LTRIM([1, 2])": NULL | ||
} | ||
*/ | ||
-- test: LTRIM DOCUMENT | ||
SELECT strings.LTRIM({a: 1}); | ||
/* result: | ||
{ | ||
"LTRIM({a: 1})": NULL | ||
} | ||
*/ | ||
|
||
-- test: LTRIM STRING wrong param | ||
SELECT strings.LTRIM(" hello ", 42); | ||
/* result: | ||
{ | ||
"LTRIM(\" hello \", 42)": NULL | ||
} | ||
*/ |
This file contains 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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
-- setup: | ||
CREATE TABLE test( | ||
a TEXT | ||
); | ||
|
||
INSERT INTO test (a) VALUES (" hello "), ("!hello!"), (" !hello! "); | ||
|
||
-- test: RTRIM TEXT default | ||
SELECT strings.RTRIM(a) FROM test; | ||
/* result: | ||
{ | ||
"RTRIM(a)": " hello" | ||
} | ||
{ | ||
"RTRIM(a)": "!hello!" | ||
} | ||
{ | ||
"RTRIM(a)": " !hello!" | ||
} | ||
*/ | ||
|
||
|
||
-- test: RTRIM TEXT with param | ||
SELECT strings.RTRIM(a, "!") FROM test; | ||
/* result: | ||
{ | ||
"RTRIM(a, \"!\")": " hello " | ||
} | ||
{ | ||
"RTRIM(a, \"!\")": "!hello" | ||
} | ||
{ | ||
"RTRIM(a, \"!\")": " !hello! " | ||
} | ||
*/ | ||
|
||
-- test: RTRIM TEXT with multiple char params | ||
SELECT strings.RTRIM(a, " !") FROM test; | ||
/* result: | ||
{ | ||
"RTRIM(a, \" !\")": " hello" | ||
} | ||
{ | ||
"RTRIM(a, \" !\")": "!hello" | ||
} | ||
{ | ||
"RTRIM(a, \" !\")": " !hello" | ||
} | ||
*/ | ||
|
||
|
||
-- test: RTRIM TEXT with multiple char params | ||
SELECT strings.RTRIM(a, "hel !") FROM test; | ||
/* result: | ||
{ | ||
"RTRIM(a, \"hel !\")": " hello" | ||
} | ||
{ | ||
"RTRIM(a, \"hel !\")": "!hello" | ||
} | ||
{ | ||
"RTRIM(a, \"hel !\")": " !hello" | ||
} | ||
*/ | ||
|
||
|
||
-- test: RTRIM BOOL | ||
SELECT strings.RTRIM(true); | ||
/* result: | ||
{ | ||
"RTRIM(true)": NULL | ||
} | ||
*/ | ||
|
||
-- test: RTRIM INT | ||
SELECT strings.RTRIM(42); | ||
/* result: | ||
{ | ||
"RTRIM(42)": NULL | ||
} | ||
*/ | ||
|
||
-- test: RTRIM DOUBLE | ||
SELECT strings.RTRIM(42.42); | ||
/* result: | ||
{ | ||
"RTRIM(42.42)": NULL | ||
} | ||
*/ | ||
|
||
-- test: RTRIM ARRAY | ||
SELECT strings.RTRIM([1, 2]); | ||
/* result: | ||
{ | ||
"RTRIM([1, 2])": NULL | ||
} | ||
*/ | ||
-- test: RTRIM DOCUMENT | ||
SELECT strings.RTRIM({a: 1}); | ||
/* result: | ||
{ | ||
"RTRIM({a: 1})": NULL | ||
} | ||
*/ | ||
|
||
-- test: RTRIM STRING wrong param | ||
SELECT strings.RTRIM(" hello ", 42); | ||
/* result: | ||
{ | ||
"RTRIM(\" hello \", 42)": NULL | ||
} | ||
*/ |
Oops, something went wrong.