mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 15:36:30 +03:00
refactor(sql): do not expose rusqlite Error type in query_map methods
We use query_and_then() instead of query_map() function now. The difference is that row processing function returns anyhow::Result, so simple fallible processing like JSON parsing can be done inside of it when calling query_map_vec() and query_map_collect() without having to resort to query_map() and iterating over all rows again afterwards.
This commit is contained in:
@@ -1101,7 +1101,10 @@ impl Context {
|
||||
" ORDER BY m.timestamp DESC,m.id DESC;"
|
||||
),
|
||||
(MessageState::InFresh, time()),
|
||||
|row| row.get::<_, MsgId>(0),
|
||||
|row| {
|
||||
let msg_id: MsgId = row.get(0)?;
|
||||
Ok(msg_id)
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
Ok(list)
|
||||
@@ -1205,7 +1208,10 @@ impl Context {
|
||||
AND IFNULL(txt_normalized, txt) LIKE ?
|
||||
ORDER BY m.timestamp,m.id;",
|
||||
(chat_id, str_like_in_text),
|
||||
|row| row.get::<_, MsgId>("id"),
|
||||
|row| {
|
||||
let msg_id: MsgId = row.get("id")?;
|
||||
Ok(msg_id)
|
||||
},
|
||||
)
|
||||
.await?
|
||||
} else {
|
||||
@@ -1234,7 +1240,10 @@ impl Context {
|
||||
AND IFNULL(txt_normalized, txt) LIKE ?
|
||||
ORDER BY m.id DESC LIMIT 1000",
|
||||
(str_like_in_text,),
|
||||
|row| row.get::<_, MsgId>("id"),
|
||||
|row| {
|
||||
let msg_id: MsgId = row.get("id")?;
|
||||
Ok(msg_id)
|
||||
},
|
||||
)
|
||||
.await?
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user