MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / placeholder_literal_token

Function placeholder_literal_token

nodedb-sql/src/dsl_bind.rs:111–127  ·  view source on GitHub ↗
(placeholder: &str, params: &[ParamValue])

Source from the content-addressed store, hash-verified

109}
110
111fn placeholder_literal_token(placeholder: &str, params: &[ParamValue]) -> Option<Token> {
112 let idx_str = placeholder.strip_prefix('$')?;
113 let idx: usize = idx_str.parse().ok()?;
114 let param = params.get(idx.checked_sub(1)?)?;
115 Some(match param {
116 ParamValue::Null => Token::make_keyword("NULL"),
117 ParamValue::Bool(true) => Token::make_keyword("TRUE"),
118 ParamValue::Bool(false) => Token::make_keyword("FALSE"),
119 ParamValue::Int64(n) => Token::Number(n.to_string(), false),
120 ParamValue::Float64(f) => Token::Number(f.to_string(), false),
121 ParamValue::Decimal(d) => Token::Number(d.to_string(), false),
122 ParamValue::Text(s) => Token::SingleQuotedString(s.clone()),
123 ParamValue::Timestamp(dt) | ParamValue::Timestamptz(dt) => {
124 Token::SingleQuotedString(dt.to_iso8601())
125 }
126 })
127}
128
129#[cfg(test)]
130mod tests {

Callers 1

bind_dslFunction · 0.85

Calls 6

to_stringMethod · 0.80
to_iso8601Method · 0.80
okMethod · 0.45
parseMethod · 0.45
getMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected