Hotfix - try_get Option<T> directly

This commit is contained in:
Billy Chan 2021-08-06 18:23:37 +08:00
parent 7e590b4a8d
commit 1eb490055e
No known key found for this signature in database
GPG Key ID: A2D690CAC7DF3CC7

View File

@ -90,35 +90,20 @@ macro_rules! try_getable_all {
#[cfg(feature = "sqlx-mysql")] #[cfg(feature = "sqlx-mysql")]
QueryResultRow::SqlxMySql(row) => { QueryResultRow::SqlxMySql(row) => {
use sqlx::Row; use sqlx::Row;
match row.try_get(column.as_str()) { row.try_get::<Option<$type>, _>(column.as_str())
Ok(v) => Ok(Some(v)), .map_err(crate::sqlx_error_to_query_err)
Err(e) => {
debug_print!("{:#?}", e.to_string());
Ok(None)
}
}
} }
#[cfg(feature = "sqlx-postgres")] #[cfg(feature = "sqlx-postgres")]
QueryResultRow::SqlxPostgres(row) => { QueryResultRow::SqlxPostgres(row) => {
use sqlx::Row; use sqlx::Row;
match row.try_get(column.as_str()) { row.try_get::<Option<$type>, _>(column.as_str())
Ok(v) => Ok(Some(v)), .map_err(crate::sqlx_error_to_query_err)
Err(e) => {
debug_print!("{:#?}", e.to_string());
Ok(None)
}
}
} }
#[cfg(feature = "sqlx-sqlite")] #[cfg(feature = "sqlx-sqlite")]
QueryResultRow::SqlxSqlite(row) => { QueryResultRow::SqlxSqlite(row) => {
use sqlx::Row; use sqlx::Row;
match row.try_get(column.as_str()) { row.try_get::<Option<$type>, _>(column.as_str())
Ok(v) => Ok(Some(v)), .map_err(crate::sqlx_error_to_query_err)
Err(e) => {
debug_print!("{:#?}", e.to_string());
Ok(None)
}
}
} }
#[cfg(feature = "mock")] #[cfg(feature = "mock")]
QueryResultRow::Mock(row) => match row.try_get(column.as_str()) { QueryResultRow::Mock(row) => match row.try_get(column.as_str()) {
@ -169,13 +154,8 @@ macro_rules! try_getable_unsigned {
#[cfg(feature = "sqlx-mysql")] #[cfg(feature = "sqlx-mysql")]
QueryResultRow::SqlxMySql(row) => { QueryResultRow::SqlxMySql(row) => {
use sqlx::Row; use sqlx::Row;
match row.try_get(column.as_str()) { row.try_get::<Option<$type>, _>(column.as_str())
Ok(v) => Ok(Some(v)), .map_err(crate::sqlx_error_to_query_err)
Err(e) => {
debug_print!("{:#?}", e.to_string());
Ok(None)
}
}
} }
#[cfg(feature = "sqlx-postgres")] #[cfg(feature = "sqlx-postgres")]
QueryResultRow::SqlxPostgres(_) => { QueryResultRow::SqlxPostgres(_) => {
@ -184,13 +164,8 @@ macro_rules! try_getable_unsigned {
#[cfg(feature = "sqlx-sqlite")] #[cfg(feature = "sqlx-sqlite")]
QueryResultRow::SqlxSqlite(row) => { QueryResultRow::SqlxSqlite(row) => {
use sqlx::Row; use sqlx::Row;
match row.try_get(column.as_str()) { row.try_get::<Option<$type>, _>(column.as_str())
Ok(v) => Ok(Some(v)), .map_err(crate::sqlx_error_to_query_err)
Err(e) => {
debug_print!("{:#?}", e.to_string());
Ok(None)
}
}
} }
#[cfg(feature = "mock")] #[cfg(feature = "mock")]
QueryResultRow::Mock(row) => match row.try_get(column.as_str()) { QueryResultRow::Mock(row) => match row.try_get(column.as_str()) {
@ -239,13 +214,8 @@ macro_rules! try_getable_mysql {
#[cfg(feature = "sqlx-mysql")] #[cfg(feature = "sqlx-mysql")]
QueryResultRow::SqlxMySql(row) => { QueryResultRow::SqlxMySql(row) => {
use sqlx::Row; use sqlx::Row;
match row.try_get(column.as_str()) { row.try_get::<Option<$type>, _>(column.as_str())
Ok(v) => Ok(Some(v)), .map_err(crate::sqlx_error_to_query_err)
Err(e) => {
debug_print!("{:#?}", e.to_string());
Ok(None)
}
}
} }
#[cfg(feature = "sqlx-postgres")] #[cfg(feature = "sqlx-postgres")]
QueryResultRow::SqlxPostgres(_) => { QueryResultRow::SqlxPostgres(_) => {