Skip to content

Commit

Permalink
runtimes/core: add string mapping for uuid fields (#1393)
Browse files Browse the repository at this point in the history
Co-authored-by: André Eriksson <[email protected]>
  • Loading branch information
fredr and eandre authored Sep 13, 2024
1 parent 2aeae55 commit b642bc9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions runtimes/core/src/sqldb/val.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use anyhow::Context;
use bytes::BytesMut;
use std::error::Error;
use tokio_postgres::types::{FromSql, IsNull, ToSql, Type};
use uuid::Uuid;

#[derive(Debug)]
pub enum RowValue {
Expand Down Expand Up @@ -60,6 +62,10 @@ impl ToSql for RowValue {
.map_err(Box::new)?;
val.to_sql(ty, out)
}
Type::UUID => {
let val = Uuid::parse_str(str).context("unable to parse uuid")?;
val.to_sql(ty, out)
}
_ => Err(format!("string not supported for column of type {}", ty).into()),
},

Expand Down

0 comments on commit b642bc9

Please sign in to comment.