Skip to content

Commit ccac77c

Browse files
committed
fmt
1 parent e4252f5 commit ccac77c

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/webserver/database/mod.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use sqlx::pool::{PoolConnection, PoolOptions};
2626
use sqlx::query::Query;
2727
use sqlx::{
2828
Any, AnyConnection, AnyPool, Arguments, Column, ConnectOptions, Decode, Either, Executor, Row,
29-
Statement, ValueRef, TypeInfo,
29+
Statement, TypeInfo, ValueRef,
3030
};
3131

3232
use self::sql::ParsedSQLStatement;
@@ -234,13 +234,13 @@ fn sql_to_json(row: &AnyRow, col: &sqlx::any::AnyColumn) -> Value {
234234
let mut raw_value = Some(raw_value);
235235
log::trace!("Decoding a value of type {:?}", col.type_info().name());
236236
let decoded = sql_nonnull_to_json(|| {
237-
raw_value.take().unwrap_or_else(|| {
238-
row.try_get_raw(col.ordinal()).unwrap()
239-
})
237+
raw_value
238+
.take()
239+
.unwrap_or_else(|| row.try_get_raw(col.ordinal()).unwrap())
240240
});
241241
log::trace!("Decoded value: {:?}", decoded);
242242
decoded
243-
},
243+
}
244244
Ok(_null) => Value::Null,
245245
Err(e) => {
246246
log::warn!("Unable to extract value from row: {:?}", e);
@@ -280,20 +280,19 @@ fn sql_nonnull_to_json<'r>(mut get_ref: impl FnMut() -> sqlx::any::AnyValueRef<'
280280
.unwrap_or_else(|e| e.to_string())
281281
.into(),
282282
"DATETIME" | "DATETIME2" | "DATETIMEOFFSET" | "TIMESTAMP" | "TIMESTAMPTZ" => {
283-
try_decode_with!(
284-
get_ref(),
285-
[chrono::NaiveDateTime, chrono::DateTime<chrono::Utc>],
286-
|v| dbg!(v).to_string()
287-
)
288-
.unwrap_or_else(|e| format!("Unable to decode date: {:?}", e))
289-
.into()
283+
try_decode_with!(
284+
get_ref(),
285+
[chrono::NaiveDateTime, chrono::DateTime<chrono::Utc>],
286+
|v| dbg!(v).to_string()
287+
)
288+
.unwrap_or_else(|e| format!("Unable to decode date: {:?}", e))
289+
.into()
290290
}
291291
"JSON" | "JSON[]" | "JSONB" | "JSONB[]" => {
292292
<&[u8] as Decode<sqlx::any::Any>>::decode(raw_value)
293293
.and_then(|rv| {
294-
serde_json::from_slice::<Value>(rv).map_err(|e| {
295-
Box::new(e) as Box<dyn std::error::Error + Sync + Send>
296-
})
294+
serde_json::from_slice::<Value>(rv)
295+
.map_err(|e| Box::new(e) as Box<dyn std::error::Error + Sync + Send>)
297296
})
298297
.unwrap_or_default()
299298
}

0 commit comments

Comments
 (0)