From 2b289157d0dc57edabc889caa49075808d48437c Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Thu, 14 Aug 2025 14:04:33 -0400 Subject: [PATCH] Properly quote sequence value --- cli/app.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cli/app.rs b/cli/app.rs index dc24f773d..d3dbe04e0 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -1450,7 +1450,7 @@ impl Limbo { writeln!( out, "INSERT INTO sqlite_sequence(name,seq) VALUES({},{});", - quote_ident(name), + sql_quote_string(name), seq )?; } @@ -1542,6 +1542,18 @@ fn quote_ident(s: &str) -> String { out } +fn sql_quote_string(s: &str) -> String { + let mut out = String::with_capacity(s.len() + 2); + out.push('\''); + for ch in s.chars() { + if ch == '\'' { + out.push('\''); + } // escape as '' + out.push(ch); + } + out.push('\''); + out +} impl Drop for Limbo { fn drop(&mut self) { self.save_history()