From e7958bebaccd26d7f2f8d3d53c0b70974682c3e4 Mon Sep 17 00:00:00 2001 From: Fernando Herrera Date: Tue, 2 Aug 2022 21:29:02 +0100 Subject: [PATCH] sqlite query without collect (#6217) --- .../nu-command/src/database/values/sqlite.rs | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/crates/nu-command/src/database/values/sqlite.rs b/crates/nu-command/src/database/values/sqlite.rs index fb3366e857..7c840723cd 100644 --- a/crates/nu-command/src/database/values/sqlite.rs +++ b/crates/nu-command/src/database/values/sqlite.rs @@ -366,16 +366,21 @@ impl CustomValue for SQLiteDatabase { } fn to_base_value(&self, span: Span) -> Result { - let db = open_sqlite_db(self.connection.as_path(span)?, span)?; - read_entire_sqlite_db(db, span).map_err(|e| { - ShellError::GenericError( - "Failed to read from SQLite database".into(), - e.to_string(), - Some(span), - None, - Vec::new(), - ) - }) + match self.statement { + None => { + let db = open_sqlite_db(self.connection.as_path(span)?, span)?; + read_entire_sqlite_db(db, span).map_err(|e| { + ShellError::GenericError( + "Failed to read from SQLite database".into(), + e.to_string(), + Some(span), + None, + Vec::new(), + ) + }) + } + Some(_) => self.collect(span), + } } fn as_any(&self) -> &dyn std::any::Any {