Skip to content

Commit

Permalink
impl column_type
Browse files Browse the repository at this point in the history
  • Loading branch information
Horusiath committed Nov 13, 2023
1 parent 5f9b4dd commit e74b4bb
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions libsql/src/hrana/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,22 @@ impl RowsInner for Rows {
.map(|s| s.as_str())
}

fn column_type(&self, _idx: i32) -> crate::Result<ValueType> {
todo!("implement")
fn column_type(&self, idx: i32) -> crate::Result<ValueType> {
let row = match self.rows.get(0) {
None => return Err(crate::Error::QueryReturnedNoRows),
Some(row) => row,
};
let cell = match row.get(idx as usize) {
None => return Err(crate::Error::ColumnNotFound(idx)),
Some(cell) => cell,
};
Ok(match cell {
proto::Value::Null => ValueType::Null,
proto::Value::Integer { .. } => ValueType::Integer,
proto::Value::Float { .. } => ValueType::Real,
proto::Value::Text { .. } => ValueType::Text,
proto::Value::Blob { .. } => ValueType::Blob,
})
}
}

Expand Down

0 comments on commit e74b4bb

Please sign in to comment.