SQL string-literal escaping. Render a `&str` as a SQL string literal: single-quote-doubled and wrapped in single quotes. Matches `standard_conforming_strings=on` behavior (PG 9.1+ default), the only mode the server runs in. Centralizes the escape so call sites can't drift into raw `format!`s without going through it — every `'foo'` written into a SQL string inside this crate goes through here.
(s: &str)
| 10 | /// without going through it — every `'foo'` written into a SQL string |
| 11 | /// inside this crate goes through here. |
| 12 | pub(crate) fn quote_string_literal(s: &str) -> String { |
| 13 | let escaped = s.replace('\'', "''"); |
| 14 | format!("'{escaped}'") |
| 15 | } |
| 16 | |
| 17 | #[cfg(test)] |
| 18 | mod tests { |