Fix SUBSTRING from/to argument construction for mssql (#947)

This commit is contained in:
Jeremy Maness 2023-08-17 06:17:57 -04:00 committed by GitHub
parent 173a6db818
commit 8bbb85356c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 153 additions and 24 deletions

View file

@ -5084,19 +5084,45 @@ fn parse_scalar_subqueries() {
#[test]
fn parse_substring() {
one_statement_parses_to("SELECT SUBSTRING('1')", "SELECT SUBSTRING('1')");
let from_for_supported_dialects = TestedDialects {
dialects: vec![
Box::new(GenericDialect {}),
Box::new(PostgreSqlDialect {}),
Box::new(AnsiDialect {}),
Box::new(SnowflakeDialect {}),
Box::new(HiveDialect {}),
Box::new(RedshiftSqlDialect {}),
Box::new(MySqlDialect {}),
Box::new(BigQueryDialect {}),
Box::new(SQLiteDialect {}),
Box::new(DuckDbDialect {}),
],
options: None,
};
one_statement_parses_to(
let from_for_unsupported_dialects = TestedDialects {
dialects: vec![Box::new(MsSqlDialect {})],
options: None,
};
from_for_supported_dialects
.one_statement_parses_to("SELECT SUBSTRING('1')", "SELECT SUBSTRING('1')");
from_for_supported_dialects.one_statement_parses_to(
"SELECT SUBSTRING('1' FROM 1)",
"SELECT SUBSTRING('1' FROM 1)",
);
one_statement_parses_to(
from_for_supported_dialects.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)");
from_for_unsupported_dialects
.one_statement_parses_to("SELECT SUBSTRING('1', 1, 3)", "SELECT SUBSTRING('1', 1, 3)");
from_for_supported_dialects
.one_statement_parses_to("SELECT SUBSTRING('1' FOR 3)", "SELECT SUBSTRING('1' FOR 3)");
}
#[test]