sql: make all queries persistent and update to upstream sqlx

&str queries are not persistent by default.  To make queries persistent,
they have to be constructed with sqlx::query.

Upstream sqlx does not contain the change that make all queries
persistent, but it is not needed anymore. but
This commit is contained in:
link2xt
2021-04-10 21:39:24 +03:00
committed by bjoern
parent 3707471266
commit 37f68459f6
14 changed files with 114 additions and 83 deletions

View File

@@ -410,7 +410,9 @@ impl Chatlist {
pub async fn dc_get_archived_cnt(context: &Context) -> Result<usize> {
let count = context
.sql
.count("SELECT COUNT(*) FROM chats WHERE blocked=0 AND archived=1;")
.count(sqlx::query(
"SELECT COUNT(*) FROM chats WHERE blocked=0 AND archived=1;",
))
.await?;
Ok(count)
}
@@ -420,7 +422,7 @@ async fn get_last_deaddrop_fresh_msg(context: &Context) -> Result<Option<MsgId>>
// sufficient as there are typically only few fresh messages.
let id = context
.sql
.query_get_value(concat!(
.query_get_value(sqlx::query(concat!(
"SELECT m.id",
" FROM msgs m",
" LEFT JOIN chats c",
@@ -429,7 +431,7 @@ async fn get_last_deaddrop_fresh_msg(context: &Context) -> Result<Option<MsgId>>
" AND m.hidden=0",
" AND c.blocked=2",
" ORDER BY m.timestamp DESC, m.id DESC;"
))
)))
.await?;
Ok(id)
}