diff options
author | Joram Wilander <jwawilander@gmail.com> | 2015-08-28 07:51:17 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2015-08-28 07:51:17 -0400 |
commit | 2bc6451e39a4080832e0b6250f536972c42b1f48 (patch) | |
tree | d250f5271e5135a81e6115530c93024cdf82fec6 | |
parent | 02bbe79aa2a71c5ebde342b2a73c3d142a359945 (diff) | |
parent | 879fa084c9bea87f655dc3025928a251a845980a (diff) | |
download | chat-2bc6451e39a4080832e0b6250f536972c42b1f48.tar.gz chat-2bc6451e39a4080832e0b6250f536972c42b1f48.tar.bz2 chat-2bc6451e39a4080832e0b6250f536972c42b1f48.zip |
Merge pull request #486 from asubset/master
Fix getParentsPosts() query
-rw-r--r-- | api/post_test.go | 4 | ||||
-rw-r--r-- | store/sql_post_store.go | 3 | ||||
-rw-r--r-- | store/sql_post_store_test.go | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/api/post_test.go b/api/post_test.go index ac9adf358..85d92de3a 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 f083a07c9..a94a1c014 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -379,7 +379,8 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S ChannelId = :ChannelId1 AND DeleteAt = 0 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 8854fb5c4..4564e2deb 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") } |