Skip to content

Commit 6537e33

Browse files
committed
chDB: Escape double quotes in database name when executing USE command
1 parent f2512a7 commit 6537e33

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src-crates/chdb/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,13 @@ impl Connection {
7070
conn: Mutex::new(conn),
7171
dylib,
7272
};
73-
// TODO: Migrate the database field to the dynamic library in the future.
74-
let db = database.trim();
75-
if !db.is_empty() {
76-
conn.execute(&format!("USE {}", db))?;
73+
{
74+
// TODO: Migrate the database field to the dynamic library in the future.
75+
let db = database.trim();
76+
if !db.is_empty() {
77+
let escaped = db.replace('"', "\"\"");
78+
conn.execute(&format!("USE \"{}\"", escaped))?;
79+
}
7780
}
7881
Ok(conn)
7982
}

0 commit comments

Comments
 (0)