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

@ -1232,6 +1232,39 @@ fn test_prewhere() {
}
}
#[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!(
clickhouse().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!(
clickhouse().verified_stmt(&format!("USE {0}{1}{0}", quote, object_name)),
Statement::Use(Use::Object(ObjectName(vec![Ident::with_quote(
quote,
object_name.to_string(),
)])))
);
}
}
}
#[test]
fn test_query_with_format_clause() {
let format_options = vec!["TabSeparated", "JSONCompact", "NULL"];