25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
skip comment-only sql file statements
SuLe69cd5831a19c
diff --git a/src-tauri/src/commands/sql_file.rs b/src-tauri/src/commands/sql_file.rsindex aa7196f864..02106f53f6 100644--- a/src-tauri/src/commands/sql_file.rs+++ b/src-tauri/src/commands/sql_file.rs@@ -178,7 +178,7 @@ impl SqlStatementSplitter {fn push_current_statement(&mut self, statements: &mut Vec<String>) {let statement = self.buffer.trim();- if !statement.is_empty() {+ if has_executable_sql(statement) {statements.push(statement.to_string());}self.buffer.clear();@@ -186,6 +186,53 @@ impl SqlStatementSplitter {}}+fn has_executable_sql(statement: &str) -> bool {+ let mut chars = statement.chars().peekable();+ let mut in_line_comment = false;+ let mut in_block_comment = false;+ let mut previous = None;++ while let Some(ch) = chars.next() {+ let next = chars.peek().copied();++ if in_line_comment {+ if ch == '\n' {+ in_line_comment = false;+ }+ previous = Some(ch);+ continue;+ }++ if in_block_comment {+ if previous == Some('*') && ch == '/' {+ in_block_comment = false;+ }+ previous = Some(ch);+ continue;+ }++ if ch == '-' && next == Some('-') {+ in_line_comment = true;+ previous = Some(ch);+ continue;+ }++ if ch == '/' && next == Some('*') {+ in_block_comment = true;+ previous = Some(ch);+ continue;+ }++ if !ch.is_whitespace() {+ return true;+ }++ previous = Some(ch);+ }++ false+}+#[tauri::command]pub async fn preview_sql_file(file_path: String) -> Result<SqlFilePreview, String> {let path = PathBuf::from(&file_path);@@ -524,7 +571,7 @@ fn statement_error_decision(affected_rows,started_at,summary,- Some(error),+ None,)],failure_count,result: Ok(true),@@ -799,6 +846,14 @@ mod tests {);assert_eq!(splitter.finish(), Vec::<String>::new());}++ #[test]+ fn skips_comment_only_tail_after_statement() {+ assert_eq!(+ split_sql_script("CREATE TABLE a(id int); -- done\n/* no more sql */").unwrap(),+ vec!["CREATE TABLE a(id int)"]+ );+ }}#[cfg(test)]@@ -946,6 +1001,7 @@ mod execution_tests {assert_eq!(decision.progress.len(), 1);assert_eq!(decision.progress[0].status, SqlFileStatus::Cancelled);assert_eq!(decision.progress[0].failure_count, 4);+ assert_eq!(decision.progress[0].error, None);}#[test]