From 86faf753bd864dcef54911d1ccba5c6785c12bdb Mon Sep 17 00:00:00 2001 From: BlacAmDK Date: Tue, 14 Mar 2023 01:11:28 +0800 Subject: [PATCH] Fix SQLite table creation sql (#8430) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description The "CREATE TABLE" statement in `into sqlite` does not add quotes to the column names, reproduction steps are below: ``` /home/xxx〉[[name,y/n];[a,y]] | into sqlite test.db Error: × Failed to prepare SQLite statement ╭─[entry #1:1:1] 1 │ [[name,y/n];[a,y]] | into sqlite test.db · ───┬─── · ╰── near "/": syntax error in CREATE TABLE IF NOT EXISTS main (name TEXT,y/n TEXT) at offset 44 ╰──── ``` # User-Facing Changes None --------- Co-authored-by: Reilly Wood --- crates/nu-command/src/database/commands/into_sqlite.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nu-command/src/database/commands/into_sqlite.rs b/crates/nu-command/src/database/commands/into_sqlite.rs index ef970013a..033e7b01d 100644 --- a/crates/nu-command/src/database/commands/into_sqlite.rs +++ b/crates/nu-command/src/database/commands/into_sqlite.rs @@ -117,7 +117,7 @@ fn action( let table_columns_creation = columns .iter() - .map(|(name, sql_type)| format!("{name} {sql_type}")) + .map(|(name, sql_type)| format!("\"{name}\" {sql_type}")) .join(","); // get the values