Fix ordering messages by timestamp in SQL
This commit is contained in:
parent
f13f55224b
commit
e6a287992a
@ -619,11 +619,11 @@ impl Query {
|
|||||||
|
|
||||||
let mut messages = Vec::new();
|
let mut messages = Vec::new();
|
||||||
for message in sqlx::query(format!(
|
for message in sqlx::query(format!(
|
||||||
r#"SELECT * FROM msgdata_{} SORT BY timestamp DESCENDING"#,
|
r#"SELECT * FROM msgdata_{} ORDER BY timestamp DESC"#,
|
||||||
chat,
|
chat,
|
||||||
).as_str()).fetch_all(&context.db).await? {
|
).as_str()).fetch_all(&context.db).await? {
|
||||||
messages.push(Message {
|
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()?,
|
timestamp: message.try_get::<i64, _>("timestamp")?.try_into()?,
|
||||||
sender: message.try_get::<String, _>("sender_id")?.into(),
|
sender: message.try_get::<String, _>("sender_id")?.into(),
|
||||||
msg_type: message.try_get::<u8,_>("msg_type")?.try_into()?,
|
msg_type: message.try_get::<u8,_>("msg_type")?.try_into()?,
|
||||||
|
Loading…
Reference in New Issue
Block a user