Skip to main content

rewrite_params

Function rewrite_params 

Source
pub fn rewrite_params(
    sql: &str,
    params: &[&dyn ToSqlValue],
) -> Result<(String, Vec<Value>), SqliteCompatError>
Expand description

Rewrite OxiSQL-style $N positional placeholders to SQLite ? placeholders, returning the reordered parameter list.

§Behaviour

  • $1, $2, … are replaced left-to-right with ?.
  • Parameters inside single-quoted string literals ('...') are preserved.
  • Double-quoted identifiers ("...") are similarly skipped.
  • The returned params vec is ordered by $N index (1-based), so $2, $1 in the SQL results in [params[1], params[0]] in the output.

§Errors

Returns SqliteCompatError::TypeMap if a placeholder references a parameter index that is out of range for the supplied params slice.