pub fn parameterize(sql: &str) -> ParameterizedSqlExpand description
Replace all SQL literals in sql with ? placeholders.
Handles:
- Integer, decimal, and scientific-notation numeric literals (
42,3.14,1e10) - Negative numeric literals when preceded by an operator (
= -5) - Single-quoted string literals, including
''-escaped quotes ('it''s') - Double-quoted identifiers are not parameterized (kept as-is)
NULL,TRUE,FALSEkeywords (case-insensitive, word-boundary aware)- Line comments (
-- …) and block comments (/* … */) are passed through unchanged (their content is never parameterized)
§Examples
use oxisql_parse::parameterize;
let p = parameterize("SELECT * FROM t WHERE id = 42 AND name = 'Alice'");
assert_eq!(p.template, "SELECT * FROM t WHERE id = ? AND name = ?");
assert_eq!(p.literals, vec!["42", "'Alice'"]);