From f9aaba757c6077040090eb694c3d5f93db872a09 Mon Sep 17 00:00:00 2001 From: aditya singh rathore Date: Wed, 11 Feb 2026 16:25:31 +0530 Subject: [PATCH 1/2] Implement DROP TABLE statement parsing and tests --- nexum_core/src/sql/parser.rs | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/nexum_core/src/sql/parser.rs b/nexum_core/src/sql/parser.rs index ee60523..30ed8e8 100644 --- a/nexum_core/src/sql/parser.rs +++ b/nexum_core/src/sql/parser.rs @@ -197,6 +197,27 @@ impl Parser { Err(anyhow!("Unsupported query type")) } } + SqlStatement::Drop { + object_type, + if_exists, + names, + .. + } => { + // Handle DROP TABLE statements parsed by sqlparser + match object_type { + ast::ObjectType::Table => { + if names.len() != 1 { + return Err(anyhow!("Can only drop one table at a time")); + } + let table_name = names[0].to_string(); + Ok(Statement::DropTable { + name: table_name, + if_exists: *if_exists, + }) + } + _ => Err(anyhow!("Only DROP TABLE is supported")), + } + } _ => Err(anyhow!("Unsupported statement type")), } } @@ -515,6 +536,20 @@ mod tests { } } + #[test] + fn test_parse_drop_table() { + let sql = "DROP TABLE users"; + let stmt = Parser::parse(sql).unwrap(); + + match stmt { + Statement::DropTable { name, if_exists } => { + assert_eq!(name, "users"); + assert!(!if_exists); + } + _ => panic!("Expected DropTable statement"), + } + } + #[test] fn test_parse_drop_table_if_exists() { let sql = "DROP TABLE IF EXISTS users"; @@ -528,4 +563,33 @@ mod tests { _ => panic!("Expected DropTable statement"), } } + + #[test] + fn test_parse_drop_table_with_quotes() { + let sql = "DROP TABLE `users`"; + let stmt = Parser::parse(sql).unwrap(); + + match stmt { + Statement::DropTable { name, if_exists } => { + assert_eq!(name, "users"); + assert!(!if_exists); + } + _ => panic!("Expected DropTable statement"), + } + } + + #[test] + fn test_parse_drop_table_sqlparser_syntax() { + // Test that sqlparser's DROP TABLE syntax also works + let sql = "DROP TABLE users"; + let stmt = Parser::parse(sql).unwrap(); + + match stmt { + Statement::DropTable { name, if_exists } => { + assert_eq!(name, "users"); + assert!(!if_exists); + } + _ => panic!("Expected DropTable statement"), + } + } } From 050f8de123679637a429a4a6ae7769d09cdfd568 Mon Sep 17 00:00:00 2001 From: aditya singh rathore Date: Wed, 11 Feb 2026 16:45:01 +0530 Subject: [PATCH 2/2] Update parser.rs --- nexum_core/src/sql/parser.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/nexum_core/src/sql/parser.rs b/nexum_core/src/sql/parser.rs index 30ed8e8..c482609 100644 --- a/nexum_core/src/sql/parser.rs +++ b/nexum_core/src/sql/parser.rs @@ -197,6 +197,7 @@ impl Parser { Err(anyhow!("Unsupported query type")) } } + SqlStatement::Drop { object_type, if_exists,