Render a single `Value` as a SQL literal. Strings are single-quote escaped; numeric / boolean / null variants are formatted directly. Returns `Err` for variants the SQL literal layer cannot represent.
(v: &Value)
| 134 | /// escaped; numeric / boolean / null variants are formatted directly. |
| 135 | /// Returns `Err` for variants the SQL literal layer cannot represent. |
| 136 | fn render_sql_literal(v: &Value) -> NodeDbResult<String> { |
| 137 | match v { |
| 138 | Value::Null => Ok("NULL".into()), |
| 139 | Value::Bool(b) => Ok(if *b { "TRUE".into() } else { "FALSE".into() }), |
| 140 | Value::Integer(i) => Ok(i.to_string()), |
| 141 | Value::Float(f) => Ok(f.to_string()), |
| 142 | Value::String(s) => Ok(quote_string_literal(s)), |
| 143 | other => Err(NodeDbError::storage(format!( |
| 144 | "metadata filter value cannot be rendered as a SQL literal: {other:?}" |
| 145 | ))), |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | /// Translate trait-level `&[Value]` parameters into owned, `ToSql`- |
| 150 | /// compatible boxes for `tokio_postgres`. Returns one boxed parameter |