fix(query_row_optional): do not treat rows with NULL as missing rows

Instead of treating NULL type error
as absence of the row,
handle NULL values with SQL.
Previously we sometimes
accidentally treated a single column
being NULL as the lack of the whole row.
This commit is contained in:
link2xt
2024-10-02 02:11:40 +00:00
parent 5711f2fe3a
commit 8a88479d8f
6 changed files with 60 additions and 22 deletions

View File

@@ -201,7 +201,8 @@ impl MimeFactory {
let (in_reply_to, references) = context
.sql
.query_row(
"SELECT mime_in_reply_to, mime_references FROM msgs WHERE id=?",
"SELECT mime_in_reply_to, IFNULL(mime_references, '')
FROM msgs WHERE id=?",
(msg.id,),
|row| {
let in_reply_to: String = row.get(0)?;