about summary refs log tree commit diff
path: root/src/db.rs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2018-04-16T12·14+0200
committerVincent Ambo <tazjin@gmail.com>2018-04-16T12·14+0200
commitc5cf911a070e7196ef3a91887158b21bc4399034 (patch)
treed577703443517521965273ad55e3f8d2c61fe6b0 /src/db.rs
parent9bc5bbff54faf5bbc29e8cc059784735e830cb01 (diff)
fix(db): Explicitly order posts in a thread
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/db.rs b/src/db.rs
index e7af0fdd4eb8..c67eed774594 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -60,12 +60,15 @@ impl Handler<GetThread> for DbExecutor {
 
     fn handle(&mut self, msg: GetThread, _: &mut Self::Context) -> Self::Result {
         use schema::threads::dsl::*;
-
+        use schema::posts::dsl::id;
+        
         let conn = self.0.get()?;
         let thread_result: Thread = threads
             .find(msg.0).first(&conn)?;
 
-        let post_list = Post::belonging_to(&thread_result).load::<Post>(&conn)?;
+        let post_list = Post::belonging_to(&thread_result)
+            .order_by(id.asc())
+            .load::<Post>(&conn)?;
 
         Ok((thread_result, post_list))
     }