Support TRIM syntax (#331)

* Support TRIM syntax

- Implement the following cases
- TRIM([BOTH | LEADING | TRAILING] <expr> [FROM <expr>])
- TRIM(<expr>)

* Resolve 1.54.0 clippy error

- Remove needless borrow

* Add test cases for TRIM
This commit is contained in:
Jiseok CHOI 2021-08-20 15:53:52 +09:00 committed by GitHub
parent 67e17b27f5
commit e548d38de8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 0 deletions

View file

@ -2747,6 +2747,26 @@ fn parse_substring() {
one_statement_parses_to("SELECT SUBSTRING('1' FOR 3)", "SELECT SUBSTRING('1' FOR 3)");
}
#[test]
fn parse_trim() {
one_statement_parses_to(
"SELECT TRIM(BOTH 'xyz' FROM 'xyzfooxyz')",
"SELECT TRIM(BOTH 'xyz' FROM 'xyzfooxyz')",
);
one_statement_parses_to(
"SELECT TRIM(LEADING 'xyz' FROM 'xyzfooxyz')",
"SELECT TRIM(LEADING 'xyz' FROM 'xyzfooxyz')",
);
one_statement_parses_to(
"SELECT TRIM(TRAILING 'xyz' FROM 'xyzfooxyz')",
"SELECT TRIM(TRAILING 'xyz' FROM 'xyzfooxyz')",
);
one_statement_parses_to("SELECT TRIM(' foo ')", "SELECT TRIM(' foo ')");
}
#[test]
fn parse_exists_subquery() {
let expected_inner = verified_query("SELECT 1");