Add support for ATTACH DATABASE (#989)

This commit is contained in:
Ophir LOJKINE 2023-10-02 13:10:56 +02:00 committed by GitHub
parent 7723ea56c5
commit 495d0a02d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 0 deletions

View file

@ -259,6 +259,24 @@ fn parse_create_table_with_strict() {
}
}
#[test]
fn parse_attach_database() {
let sql = "ATTACH DATABASE 'test.db' AS test";
let verified_stmt = sqlite().verified_stmt(sql);
assert_eq!(sql, format!("{}", verified_stmt));
match verified_stmt {
Statement::AttachDatabase {
schema_name,
database_file_name: Expr::Value(Value::SingleQuotedString(literal_name)),
database: true,
} => {
assert_eq!(schema_name.value, "test");
assert_eq!(literal_name, "test.db");
}
_ => unreachable!(),
}
}
fn sqlite() -> TestedDialects {
TestedDialects {
dialects: vec![Box::new(SQLiteDialect {})],