Substitute `$N` placeholders in `sql` with the rendered SQL literal form of each value. Returns the new SQL or a typed error message suitable for `42P02`.
(sql: &str, params: &[Value])
| 473 | /// form of each value. Returns the new SQL or a typed error message |
| 474 | /// suitable for `42P02`. |
| 475 | fn inline_params(sql: &str, params: &[Value]) -> Result<String, String> { |
| 476 | // Render every value first so a render failure aborts the whole |
| 477 | // substitution rather than partially rewriting placeholders — a |
| 478 | // partially-rewritten SQL would re-create the silent-wrong pattern |
| 479 | // the trait contract guards against. |
| 480 | let literals: Vec<String> = params |
| 481 | .iter() |
| 482 | .map(value_to_sql_literal) |
| 483 | .collect::<Result<Vec<_>, _>>()?; |
| 484 | Ok( |
| 485 | crate::control::server::pgwire::handler::prepared::sql_placeholder::rewrite_sql_placeholders( |
| 486 | sql, &literals, |
| 487 | ), |
| 488 | ) |
| 489 | } |
| 490 | |
| 491 | /// Render a `nodedb_types::Value` as a SQL literal usable in |
| 492 | /// expression position. |
no test coverage detected