codegen: fix ColumnType to Rust type resolution (#2313)

This commit is contained in:
Billy Chan 2024-08-23 17:28:16 +08:00 committed by GitHub
parent 4553160685
commit 01cd94a83b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,7 +60,6 @@ impl Column {
}, },
ColumnType::Timestamp => match date_time_crate { ColumnType::Timestamp => match date_time_crate {
DateTimeCrate::Chrono => "DateTimeUtc".to_owned(), DateTimeCrate::Chrono => "DateTimeUtc".to_owned(),
// ColumnType::Timpestamp(_) => time::PrimitiveDateTime: https://docs.rs/sqlx/0.3.5/sqlx/postgres/types/index.html#time
DateTimeCrate::Time => "TimeDateTime".to_owned(), DateTimeCrate::Time => "TimeDateTime".to_owned(),
}, },
ColumnType::TimestampWithTimeZone => match date_time_crate { ColumnType::TimestampWithTimeZone => match date_time_crate {
@ -77,6 +76,14 @@ impl Column {
ColumnType::Array(column_type) => { ColumnType::Array(column_type) => {
format!("Vec<{}>", write_rs_type(column_type, date_time_crate)) format!("Vec<{}>", write_rs_type(column_type, date_time_crate))
} }
ColumnType::Bit(None | Some(1)) => "bool".to_owned(),
ColumnType::Bit(_) | ColumnType::VarBit(_) => "Vec<u8>".to_owned(),
ColumnType::Year => "i32".to_owned(),
ColumnType::Interval(_, _)
| ColumnType::Cidr
| ColumnType::Inet
| ColumnType::MacAddr
| ColumnType::LTree => "String".to_owned(),
_ => unimplemented!(), _ => unimplemented!(),
} }
} }