pub fn quote(s: &str) -> String {
format!("'{}'", s.replace("'", "''"))
}
pub fn quote_identifier(s: &str) -> String {
format!("\"{}\"", s.replace("\"", "\"\""))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_quote_simple() {
assert_eq!(quote("hello"), "'hello'");
}
#[test]
fn test_quote_with_single_quote() {
assert_eq!(quote("O'Reilly"), "'O''Reilly'");
}
#[test]
fn test_quote_empty() {
assert_eq!(quote(""), "''");
}
#[test]
fn test_quote_identifier() {
assert_eq!(quote_identifier("users"), "\"users\"");
assert_eq!(quote_identifier("user\"name"), "\"user\"\"name\"");
}
}