From 9ae4d4b59ed6f56cb1f47d6fd9ecf7c0d1e7b563 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Sat, 27 Jun 2026 15:00:08 +0800 Subject: [PATCH] fix(duckdb): allow opening non-existent database files --- crates/dbx-core/src/db/duckdb_driver.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/dbx-core/src/db/duckdb_driver.rs b/crates/dbx-core/src/db/duckdb_driver.rs index 8ef56bea7..d64ee9751 100644 --- a/crates/dbx-core/src/db/duckdb_driver.rs +++ b/crates/dbx-core/src/db/duckdb_driver.rs @@ -39,7 +39,13 @@ fn validate_duckdb_path(path: &str) -> Result<(), String> { return Err(format!("Database file path is a directory, not a file: {}", path)); } if !path_obj.exists() { - return Err(format!("Database file does not exist: {}", path)); + // DuckDB creates a new database file on open when the parent directory + // exists. Only reject paths whose parent directory is missing. + if let Some(parent) = path_obj.parent() { + if !parent.as_os_str().is_empty() && !parent.exists() { + return Err(format!("Parent directory does not exist: {}", parent.display())); + } + } } Ok(()) }