From e6a287992a5fcc752a279d9b86b14d8af3d3e86c Mon Sep 17 00:00:00 2001 From: EliasSchriefer Date: Thu, 16 Dec 2021 18:38:54 +0100 Subject: [PATCH] Fix ordering messages by timestamp in SQL --- src/graphql.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/graphql.rs b/src/graphql.rs index 8675012..a1c54e5 100644 --- a/src/graphql.rs +++ b/src/graphql.rs @@ -619,11 +619,11 @@ impl Query { let mut messages = Vec::new(); for message in sqlx::query(format!( - r#"SELECT * FROM msgdata_{} SORT BY timestamp DESCENDING"#, + r#"SELECT * FROM msgdata_{} ORDER BY timestamp DESC"#, chat, ).as_str()).fetch_all(&context.db).await? { messages.push(Message { - id: ID::from(message.try_get::("id")?), + id: ID::from(message.try_get::("msg_id")?), timestamp: message.try_get::("timestamp")?.try_into()?, sender: message.try_get::("sender_id")?.into(), msg_type: message.try_get::("msg_type")?.try_into()?,