From 3a983bb5db6b980483c60405393643a5e8972686 Mon Sep 17 00:00:00 2001 From: nils-degroot <53556985+nils-degroot@users.noreply.github.com> Date: Sun, 10 Mar 2024 20:14:21 +0100 Subject: [PATCH] Improve error message for `into sqlite` with empty records (#12149) - fixes #12126 # Description This pr improves the error message for issue #12126 # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/database/commands/into_sqlite.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/nu-command/src/database/commands/into_sqlite.rs b/crates/nu-command/src/database/commands/into_sqlite.rs index 6a4ae6cf47..fb74753155 100644 --- a/crates/nu-command/src/database/commands/into_sqlite.rs +++ b/crates/nu-command/src/database/commands/into_sqlite.rs @@ -213,6 +213,16 @@ fn insert_in_transaction( Some(val) => val.as_record()?, }; + if first_val.is_empty() { + Err(ShellError::GenericError { + error: "Failed to create table".into(), + msg: "Cannot create table without columns".to_string(), + span: Some(span), + help: None, + inner: vec![], + })?; + } + let table_name = table.name().clone(); let tx = table.try_init(first_val)?;