Implement SUBSTRING(col [FROM <expr>] [FOR <expr>]) syntax (#293)

This commit is contained in:
Daniël Heres 2021-02-07 16:06:50 +01:00 committed by GitHub
parent 8a214f9919
commit 6f0b2dcd92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 3 deletions

View file

@ -2598,6 +2598,23 @@ fn parse_scalar_subqueries() {
);
}
#[test]
fn parse_substring() {
one_statement_parses_to("SELECT SUBSTRING('1')", "SELECT SUBSTRING('1')");
one_statement_parses_to(
"SELECT SUBSTRING('1' FROM 1)",
"SELECT SUBSTRING('1' FROM 1)",
);
one_statement_parses_to(
"SELECT SUBSTRING('1' FROM 1 FOR 3)",
"SELECT SUBSTRING('1' FROM 1 FOR 3)",
);
one_statement_parses_to("SELECT SUBSTRING('1' FOR 3)", "SELECT SUBSTRING('1' FOR 3)");
}
#[test]
fn parse_exists_subquery() {
let expected_inner = verified_query("SELECT 1");

View file

@ -25,10 +25,9 @@ macro_rules! tpch_tests {
#[test]
fn $name() {
let dialect = GenericDialect {};
let res = Parser::parse_sql(&dialect, QUERIES[$value -1]);
// Ignore 6.sql and 22.sql
if $value != 6 && $value != 22 {
// Ignore 6.sql
if $value != 6 {
assert!(res.is_ok());
}
}