Fix ordering messages by timestamp in SQL

This commit is contained in:
Elias Schriefer 2021-12-16 18:38:54 +01:00
parent f13f55224b
commit e6a287992a

View File

@ -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::<String, _>("id")?),
id: ID::from(message.try_get::<String, _>("msg_id")?),
timestamp: message.try_get::<i64, _>("timestamp")?.try_into()?,
sender: message.try_get::<String, _>("sender_id")?.into(),
msg_type: message.try_get::<u8,_>("msg_type")?.try_into()?,