From b47e3a990e530bb07b5cef6275067f0b6fe487c7 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Tue, 27 May 2025 20:43:46 -0300 Subject: [PATCH] impl ToSqlString for COMMIT stmt --- .../src/to_sql_string/stmt/mod.rs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/vendored/sqlite3-parser/src/to_sql_string/stmt/mod.rs b/vendored/sqlite3-parser/src/to_sql_string/stmt/mod.rs index be33c9e03..33d8b5a99 100644 --- a/vendored/sqlite3-parser/src/to_sql_string/stmt/mod.rs +++ b/vendored/sqlite3-parser/src/to_sql_string/stmt/mod.rs @@ -37,14 +37,17 @@ impl ToSqlString for ast::Stmt { } // TODO: not sure where name is applied here // https://www.sqlite.org/lang_transaction.html - Self::Begin(transaction_type, _) => { + Self::Begin(transaction_type, _name) => { let t_type = transaction_type.map_or("", |t_type| match t_type { - ast::TransactionType::Deferred => "DEFERRED ", - ast::TransactionType::Exclusive => "EXCLUSIVE ", - ast::TransactionType::Immediate => "IMMEDIATE ", + ast::TransactionType::Deferred => " DEFERRED", + ast::TransactionType::Exclusive => " EXCLUSIVE", + ast::TransactionType::Immediate => " IMMEDIATE", }); format!("BEGIN {}TRANSACTION", t_type) } + // END or COMMIT are equivalent here, so just defaulting to COMMIT + // TODO: again there are no names in the docs + Self::Commit(_name) => "COMMIT".to_string(), Self::Select(select) => select.to_sql_string(context), _ => todo!(), } @@ -121,11 +124,13 @@ 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, "BEGIN"); - to_sql_string_test!(test_transaction_deferred, "BEGIN DEFERRED TRANSACTION"); + to_sql_string_test!(test_transaction_deferred, "BEGIN DEFERRED"); - to_sql_string_test!(test_transaction_immediate, "BEGIN IMMEDIATE TRANSACTION"); + to_sql_string_test!(test_transaction_immediate, "BEGIN IMMEDIATE"); - to_sql_string_test!(test_transaction_exclusive, "BEGIN EXCLUSIVE TRANSACTION"); + to_sql_string_test!(test_transaction_exclusive, "BEGIN EXCLUSIVE"); + + to_sql_string_test!(test_commit, "COMMIT"); }