Skip to content

Commit e2a8d68

Browse files
authored
runtimes/core: add support for converting to sql enum (#1848)
1 parent 142a05f commit e2a8d68

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

runtimes/core/src/sqldb/val.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ impl ToSql for PValue {
9393
let val = Uuid::parse_str(str).context("unable to parse uuid")?;
9494
val.to_sql(ty, out)
9595
}
96-
_ => Err(format!("string not supported for column of type {}", ty).into()),
96+
_ => {
97+
if let Kind::Enum(_) = ty.kind() {
98+
str.to_sql(ty, out)
99+
} else {
100+
Err(format!("string not supported for column of type {}", ty).into())
101+
}
102+
}
97103
},
98104

99105
PValue::Number(num) => match *ty {
@@ -235,7 +241,8 @@ impl ToSql for PValue {
235241
| Type::TIMESTAMPTZ
236242
| Type::DATE
237243
| Type::TIME
238-
) || matches!(ty.kind(), Kind::Array(ty) if <PValue as ToSql>::accepts(ty))
244+
) || matches!(ty.kind(), Kind::Enum(_))
245+
|| matches!(ty.kind(), Kind::Array(ty) if <PValue as ToSql>::accepts(ty))
239246
}
240247
to_sql_checked!();
241248
}

0 commit comments

Comments
 (0)