From 4aafff7f83359531cb2e110f4b7c080e33407cc3 Mon Sep 17 00:00:00 2001 From: Jason Rossman Date: Wed, 26 Aug 2015 15:59:54 -0600 Subject: Fix getParentsPosts for postgresql --- store/sql_post_store.go | 1 + 1 file changed, 1 insertion(+) diff --git a/store/sql_post_store.go b/store/sql_post_store.go index 479caf838..81405c620 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -343,6 +343,7 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S WHERE ChannelId = :ChannelId1 AND DeleteAt = 0 + AND RootId <> '' ORDER BY CreateAt DESC LIMIT :Limit OFFSET :Offset) q3) q1 ON q1.RootId = q2.RootId WHERE -- cgit v1.2.3-1-g7c22 From 879fa084c9bea87f655dc3025928a251a845980a Mon Sep 17 00:00:00 2001 From: Jason Rossman Date: Thu, 27 Aug 2015 12:45:47 -0600 Subject: fix GetParentPosts() query --- api/post_test.go | 4 ++-- store/sql_post_store.go | 4 ++-- store/sql_post_store_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/post_test.go b/api/post_test.go index cbba83af6..af2e4f326 100644 --- a/api/post_test.go +++ b/api/post_test.go @@ -331,7 +331,7 @@ func TestGetPosts(t *testing.T) { t.Fatal("wrong order") } - if len(r1.Posts) != 4 { + if len(r1.Posts) != 2 { // 3a1 and 3; 3a1's parent already there t.Fatal("wrong size") } @@ -345,7 +345,7 @@ func TestGetPosts(t *testing.T) { t.Fatal("wrong order") } - if len(r2.Posts) != 4 { + if len(r2.Posts) != 3 { // 2 and 1a1; + 1a1's parent t.Log(r2.Posts) t.Fatal("wrong size") } diff --git a/store/sql_post_store.go b/store/sql_post_store.go index 81405c620..78361270e 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -343,9 +343,9 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S WHERE ChannelId = :ChannelId1 AND DeleteAt = 0 - AND RootId <> '' ORDER BY CreateAt DESC - LIMIT :Limit OFFSET :Offset) q3) q1 ON q1.RootId = q2.RootId + LIMIT :Limit OFFSET :Offset) q3 + WHERE q3.RootId != '') q1 ON q1.RootId = q2.Id WHERE ChannelId = :ChannelId2 AND DeleteAt = 0 diff --git a/store/sql_post_store_test.go b/store/sql_post_store_test.go index 336a20d98..5855607fd 100644 --- a/store/sql_post_store_test.go +++ b/store/sql_post_store_test.go @@ -374,7 +374,7 @@ func TestPostStoreGetPostsWtihDetails(t *testing.T) { t.Fatal("invalid order") } - if len(r1.Posts) != 6 { + if len(r1.Posts) != 5 { //the last 4, + o1 (o3 and o2a's parent) t.Fatal("wrong size") } -- cgit v1.2.3-1-g7c22