From 7432e67da13041145556190984031779e2b29aa6 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Tue, 30 Jul 2024 21:52:28 +0800 Subject: [PATCH] don't force stripping ansi codes from strings in `stor` (#13464) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description The current version of `stor` forces stripping ansi code coloring from all the strings. In this PR, I propose to keep strings unchanged. The logic behind the proposed changes was best described in the [discord](https://discord.com/channels/601130461678272522/601130461678272524/1266387441074442272): image with proposed changes we can store colored output: ``` stor reset; stor create --table-name test --columns {a: str}; ls | table | {a: $in} | stor insert --table-name test | null; stor open | query db 'select a from test' | get a.0 ``` image # User-Facing Changes If one was using `stor` together with ansi colored input, and then was querying `stor` with search operations, they might break. But I don't think that it is a big problem, as one will just need to use `ansi reset` before storing data. # Tests + Formatting Tests are okay. Thanks to @fdncred for spending time to help me write these changes 🙏 --- crates/nu-command/src/database/values/sqlite.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/nu-command/src/database/values/sqlite.rs b/crates/nu-command/src/database/values/sqlite.rs index f253ba1cbd..5d0f7d1fe3 100644 --- a/crates/nu-command/src/database/values/sqlite.rs +++ b/crates/nu-command/src/database/values/sqlite.rs @@ -424,11 +424,7 @@ pub fn value_to_sql(value: Value) -> Result, ShellError Value::Filesize { val, .. } => Box::new(val), Value::Duration { val, .. } => Box::new(val), Value::Date { val, .. } => Box::new(val), - Value::String { val, .. } => { - // don't store ansi escape sequences in the database - // escape single quotes - Box::new(nu_utils::strip_ansi_unlikely(&val).into_owned()) - } + Value::String { val, .. } => Box::new(val), Value::Binary { val, .. } => Box::new(val), Value::Nothing { .. } => Box::new(rusqlite::types::Null), val => {