MCPcopy Create free account
hub / github.com/douglance/devsql / row_to_values

Function row_to_values

crates/vcsql/src/sql/engine.rs:157–186  ·  view source on GitHub ↗
(row: &Row, col_count: usize)

Source from the content-addressed store, hash-verified

155}
156
157fn row_to_values(row: &Row, col_count: usize) -> Vec<Value> {
158 (0..col_count)
159 .map(|i| {
160 if let Ok(v) = row.get::<_, Option<i64>>(i) {
161 match v {
162 Some(n) => Value::Number(n.into()),
163 None => Value::Null,
164 }
165 } else if let Ok(v) = row.get::<_, Option<f64>>(i) {
166 match v {
167 Some(n) => {
168 if let Some(num) = serde_json::Number::from_f64(n) {
169 Value::Number(num)
170 } else {
171 Value::String(n.to_string())
172 }
173 }
174 None => Value::Null,
175 }
176 } else if let Ok(v) = row.get::<_, Option<String>>(i) {
177 match v {
178 Some(s) => Value::String(s),
179 None => Value::Null,
180 }
181 } else {
182 Value::Null
183 }
184 })
185 .collect()
186}
187
188/// The result of a SQL query execution.
189#[derive(Debug)]

Callers 1

executeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected