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

@@ -2860,7 +2860,9 @@ pub(crate) async fn get_chat_cnt(context: &Context) -> Result<usize, Error> {
// no database, no chats - this is no error (needed eg. for information)
let count = context
.sql
.count("SELECT COUNT(*) FROM chats WHERE id>9 AND blocked=0;")
.count(sqlx::query(
"SELECT COUNT(*) FROM chats WHERE id>9 AND blocked=0;",
))
.await?;
Ok(count as usize)
} else {
@@ -3030,7 +3032,10 @@ pub(crate) async fn delete_and_reset_all_device_msgs(context: &Context) -> Resul
.sql
.execute(sqlx::query("DELETE FROM msgs WHERE from_id=?;").bind(DC_CONTACT_ID_DEVICE as i32))
.await?;
context.sql.execute("DELETE FROM devmsglabels;").await?;
context
.sql
.execute(sqlx::query("DELETE FROM devmsglabels;"))
.await?;
Ok(())
}