Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #78 from prisma/MoreEnums
Browse files Browse the repository at this point in the history
More Enums
  • Loading branch information
do4gr authored Feb 4, 2020
2 parents 963189d + ddef301 commit 29a975d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.2.0-alpha.2

- Implement support for Arrays of Enums

## v0.2.0-alpha.1

Breaking changes ahead
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quaint"
version = "0.2.0-alpha.1"
version = "0.2.0-alpha.2"
authors = [
"Julius de Bruijn <bruijn@prisma.io>",
"Katharina Fey <kookie@spacekookie.de>",
Expand Down
33 changes: 29 additions & 4 deletions src/connector/postgres/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,35 @@ impl GetRow for PostgresRow {
None => ParameterizedValue::Null,
},
ref x => match x.kind() {
Kind::Enum(_) => {
let val: EnumString = row.try_get(i)?;
ParameterizedValue::Enum(val.value.into())
}
Kind::Enum(_) => match row.try_get(i)? {
Some(val) => {
let val: EnumString = val;
ParameterizedValue::Enum(val.value.into())
}
None => ParameterizedValue::Null,
},
Kind::Array(inner) => match inner.kind() {
Kind::Enum(_) => match row.try_get(i)? {
Some(val) => {
let val: Vec<EnumString> = val;
ParameterizedValue::Array(
val.into_iter()
.map(|x| ParameterizedValue::Enum(x.value.into()))
.collect(),
)
}
None => ParameterizedValue::Null,
},
_ => match row.try_get(i)? {
Some(val) => {
let val: Vec<String> = val;
ParameterizedValue::Array(
val.into_iter().map(|x| ParameterizedValue::Text(x.into())).collect(),
)
}
None => ParameterizedValue::Null,
},
},
_ => match row.try_get(i)? {
Some(val) => {
let val: String = val;
Expand Down

0 comments on commit 29a975d

Please sign in to comment.