Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(query_results): add support for more column types #41

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/helpers/query_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,30 @@ impl QueryResult {
ColumnType::UserDefinedType { field_types, .. } => {
Self::parse_udt(column.as_udt().unwrap(), field_types)
}
_ => "ColumnType currently not implemented".into(),
ColumnType::Boolean => serde_json::Value::Bool(column.as_boolean().unwrap()),
ColumnType::Inet => serde_json::Value::String(column.as_inet().unwrap().to_string()),
ColumnType::Double => serde_json::Value::Number(
serde_json::Number::from_f64(column.as_double().unwrap()).unwrap(),
),
ColumnType::SmallInt => serde_json::Value::Number(
serde_json::Number::from_f64(column.as_smallint().unwrap() as f64).unwrap(),
),
ColumnType::TinyInt => serde_json::Value::Number(
serde_json::Number::from_f64(column.as_tinyint().unwrap() as f64).unwrap(),
),
ColumnType::BigInt => "ColumnType BigInt not supported yet".into(),
ColumnType::Decimal => "ColumnType Decimal not supported yet".into(),
ColumnType::Duration => "ColumnType Duration not supported yet".into(),
ColumnType::Custom(_) => "ColumnType Custom not supported yet".into(),
ColumnType::Blob => "ColumnType Blob not supported yet".into(),
ColumnType::Counter => "ColumnType Counter not supported yet".into(),
ColumnType::List(_) => "ColumnType List not supported yet".into(),
ColumnType::Map(_, _) => "ColumnType Map not supported yet".into(),
ColumnType::Set(_) => "ColumnType Set not supported yet".into(),
ColumnType::Time => "ColumnType Time not supported yet".into(),
ColumnType::Timeuuid => "ColumnType Timeuuid not supported yet".into(),
ColumnType::Tuple(_) => "ColumnType Tuple not supported yet".into(),
ColumnType::Varint => "ColumnType Varint not supported yet".into(),
},
None => serde_json::Value::Null,
}
Expand Down
Loading