feat: support different USE statement syntaxes (#1387)

This commit is contained in:
Kacper Muda 2024-08-23 17:42:51 +02:00 committed by GitHub
parent 19e694aa91
commit 7282ce22f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 386 additions and 17 deletions

View file

@ -621,6 +621,38 @@ fn parse_mssql_declare() {
);
}
#[test]
fn parse_use() {
let valid_object_names = [
"mydb",
"SCHEMA",
"DATABASE",
"CATALOG",
"WAREHOUSE",
"DEFAULT",
];
let quote_styles = ['\'', '"'];
for object_name in &valid_object_names {
// Test single identifier without quotes
assert_eq!(
ms().verified_stmt(&format!("USE {}", object_name)),
Statement::Use(Use::Object(ObjectName(vec![Ident::new(
object_name.to_string()
)])))
);
for &quote in &quote_styles {
// Test single identifier with different type of quotes
assert_eq!(
ms().verified_stmt(&format!("USE {}{}{}", quote, object_name, quote)),
Statement::Use(Use::Object(ObjectName(vec![Ident::with_quote(
quote,
object_name.to_string(),
)])))
);
}
}
}
fn ms() -> TestedDialects {
TestedDialects {
dialects: vec![Box::new(MsSqlDialect {})],