Skip to content

Commit 9632d50

Browse files
committed
Fixup
1 parent 0e99349 commit 9632d50

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/query/json.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@ impl FromQueryResult for JsonValue {
99
macro_rules! try_get_type {
1010
( $type: ty, $col: ident ) => {
1111
if let Ok(v) = res.try_get::<Option<$type>>(pre, &$col) {
12-
map.insert(
13-
$col.to_owned(),
14-
json!(v),
15-
);
12+
map.insert($col.to_owned(), json!(v));
1613
continue;
1714
}
18-
}
15+
};
1916
}
2017
match &res.row {
2118
#[cfg(feature = "sqlx-mysql")]
@@ -58,9 +55,9 @@ impl FromQueryResult for JsonValue {
5855
match_mysql_type!(chrono::DateTime<chrono::Utc>);
5956
#[cfg(feature = "with-rust_decimal")]
6057
match_mysql_type!(rust_decimal::Decimal);
61-
try_get_type!(String, col);
6258
#[cfg(feature = "with-json")]
6359
try_get_type!(serde_json::Value, col);
60+
try_get_type!(String, col);
6461
#[cfg(feature = "with-uuid")]
6562
try_get_type!(uuid::Uuid, col);
6663
try_get_type!(Vec<u8>, col);
@@ -106,9 +103,9 @@ impl FromQueryResult for JsonValue {
106103
match_postgres_type!(chrono::DateTime<chrono::FixedOffset>);
107104
#[cfg(feature = "with-rust_decimal")]
108105
match_postgres_type!(rust_decimal::Decimal);
109-
try_get_type!(String, col);
110106
#[cfg(feature = "with-json")]
111107
try_get_type!(serde_json::Value, col);
108+
try_get_type!(String, col);
112109
#[cfg(feature = "with-uuid")]
113110
try_get_type!(uuid::Uuid, col);
114111
try_get_type!(Vec<u8>, col);
@@ -150,6 +147,8 @@ impl FromQueryResult for JsonValue {
150147
match_sqlite_type!(chrono::NaiveTime);
151148
#[cfg(feature = "with-chrono")]
152149
match_sqlite_type!(chrono::NaiveDateTime);
150+
#[cfg(feature = "with-json")]
151+
try_get_type!(serde_json::Value, col);
153152
try_get_type!(String, col);
154153
#[cfg(feature = "with-uuid")]
155154
try_get_type!(uuid::Uuid, col);

tests/timestamp_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub async fn create_applog(db: &DatabaseConnection) -> Result<(), DbErr> {
4242
Some(json!({
4343
"id": 1,
4444
"action": "Testing",
45-
"json": r#""HI""#,
45+
"json": "HI",
4646
"created_at": "2021-09-17 09:50:20",
4747
}))
4848
);

0 commit comments

Comments
 (0)