Skip to content

Commit

Permalink
add enum to test_all_types
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause committed Apr 21, 2024
1 parent 528cf3a commit 848a068
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/test_all_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ fn test_all_types() -> crate::Result<()> {
// union is currently blocked by https://github.com/duckdb/duckdb/pull/11326
"union",
// these remaining types are not yet supported by duckdb-rs
"small_enum",
"medium_enum",
"large_enum",
"struct",
"struct_of_arrays",
"array_of_structs",
Expand Down Expand Up @@ -349,6 +346,21 @@ fn test_single(idx: &mut i32, column: String, value: ValueRef) {
),
_ => assert_eq!(value, ValueRef::Null),
},
"small_enum" => match idx {
0 => assert_eq!(value.to_owned(), Value::Enum("DUCK_DUCK_ENUM".to_string())),
1 => assert_eq!(value.to_owned(), Value::Enum("GOOSE".to_string())),
_ => assert_eq!(value, ValueRef::Null),
},
"medium_enum" => match idx {
0 => assert_eq!(value.to_owned(), Value::Enum("enum_0".to_string())),
1 => assert_eq!(value.to_owned(), Value::Enum("enum_1".to_string())),
_ => assert_eq!(value, ValueRef::Null),
},
"large_enum" => match idx {
0 => assert_eq!(value.to_owned(), Value::Enum("enum_0".to_string())),
1 => assert_eq!(value.to_owned(), Value::Enum("enum_69999".to_string())),
_ => assert_eq!(value, ValueRef::Null),
},
_ => todo!("{column:?}"),
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/types/value_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ impl From<ValueRef<'_>> for Value {
EnumType::UInt16(res) => res.values(),
EnumType::UInt32(res) => res.values(),
},
).to_owned();
)
.to_owned();

if let Value::Text(s) = value {
Value::Enum(s)
Expand Down

0 comments on commit 848a068

Please sign in to comment.