diff --git a/simulator/generation/expr.rs b/simulator/generation/expr.rs index f17fe2044..e9e7da184 100644 --- a/simulator/generation/expr.rs +++ b/simulator/generation/expr.rs @@ -256,7 +256,7 @@ impl ArbitraryFrom<&SimulatorEnv> for ast::Literal { rng.gen_range(-1e10..1e10).to_string() } }), - 1 => ast::Literal::String(gen_random_text(rng)), + 1 => ast::Literal::String(format!("'{}'", gen_random_text(rng))), 2 => ast::Literal::Blob(hex::encode(gen_random_text(rng).as_bytes().to_vec())), // TODO: skip Keyword 3 => continue, diff --git a/simulator/model/table.rs b/simulator/model/table.rs index ffe779f5e..62ef9d74c 100644 --- a/simulator/model/table.rs +++ b/simulator/model/table.rs @@ -256,7 +256,7 @@ impl From for ast::Literal { Value::Null => Self::Null, Value::Integer(i) => Self::Numeric(i.to_string()), Value::Float(f) => Self::Numeric(f.to_string()), - Value::Text(string) => Self::String(string), + Value::Text(string) => Self::String(format!("'{}'", string)), Value::Blob(blob) => Self::Blob(hex::encode(blob)), } } diff --git a/vendored/sqlite3-parser/src/to_sql_string/expr.rs b/vendored/sqlite3-parser/src/to_sql_string/expr.rs index bb4cf4296..7727543da 100644 --- a/vendored/sqlite3-parser/src/to_sql_string/expr.rs +++ b/vendored/sqlite3-parser/src/to_sql_string/expr.rs @@ -369,12 +369,6 @@ impl Display for ast::LikeOperator { } } -/// Sanitaizes a string literal by removing single quote at front and back -/// and escaping double single quotes -pub fn sanitize_string(input: &str) -> String { - input[1..input.len() - 1].replace("''", "'").to_string() -} - impl Display for ast::Literal { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( @@ -388,7 +382,7 @@ impl Display for ast::Literal { Self::Keyword(keyword) => keyword.clone(), Self::Null => "NULL".to_string(), Self::Numeric(num) => num.clone(), - Self::String(s) => format!("'{}'", sanitize_string(s)), + Self::String(s) => s.clone(), } ) }