mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-24 19:44:21 +01:00
impl ToSqlString for BEGIN stmt
This commit is contained in:
@@ -35,6 +35,16 @@ impl ToSqlString for ast::Stmt {
|
||||
db_name.to_sql_string(context)
|
||||
)
|
||||
}
|
||||
// TODO: not sure where name is applied here
|
||||
// https://www.sqlite.org/lang_transaction.html
|
||||
Self::Begin(transaction_type, _) => {
|
||||
let t_type = transaction_type.map_or("", |t_type| match t_type {
|
||||
ast::TransactionType::Deferred => "DEFERRED ",
|
||||
ast::TransactionType::Exclusive => "EXCLUSIVE ",
|
||||
ast::TransactionType::Immediate => "IMMEDIATE ",
|
||||
});
|
||||
format!("BEGIN {}TRANSACTION", t_type)
|
||||
}
|
||||
Self::Select(select) => select.to_sql_string(context),
|
||||
_ => todo!(),
|
||||
}
|
||||
@@ -110,4 +120,12 @@ mod tests {
|
||||
);
|
||||
|
||||
to_sql_string_test!(test_attach, "ATTACH './test.db' AS test_db");
|
||||
|
||||
to_sql_string_test!(test_transaction, "BEGIN TRANSACTION");
|
||||
|
||||
to_sql_string_test!(test_transaction_deferred, "BEGIN DEFERRED TRANSACTION");
|
||||
|
||||
to_sql_string_test!(test_transaction_immediate, "BEGIN IMMEDIATE TRANSACTION");
|
||||
|
||||
to_sql_string_test!(test_transaction_exclusive, "BEGIN EXCLUSIVE TRANSACTION");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user