Skip to content

Commit

Permalink
fix: SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
movsb committed Aug 7, 2024
1 parent 6acecfe commit 2caaea8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions service/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (s *Service) ListComments(ctx context.Context, in *proto.ListCommentsReques
stmt.InnerJoin("posts", "comments.post_id = posts.id AND posts.status = 'public'")
}
if len(in.Types) > 0 {
stmt.InnerJoin(`posts`, `comments.post_id = posts.id AND posts.type in ?`, in.Types)
stmt.InnerJoin(`posts`, `comments.post_id = posts.id AND posts.type in (?)`, in.Types)
}
stmt.MustFind(&parents)
}
Expand All @@ -300,7 +300,7 @@ func (s *Service) ListComments(ctx context.Context, in *proto.ListCommentsReques
stmt.InnerJoin("posts", "comments.post_id = posts.id AND posts.status = 'public'")
}
if len(in.Types) > 0 {
stmt.InnerJoin(`posts`, `comments.post_id = posts.id AND posts.type in ?`, in.Types)
stmt.InnerJoin(`posts`, `comments.post_id = posts.id AND posts.type in (?)`, in.Types)
}
stmt.MustFind(&children)
}
Expand Down
2 changes: 1 addition & 1 deletion service/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *Service) ListPosts(ctx context.Context, in *proto.ListPostsRequest) (*p
stmt := s.posts().Limit(int64(in.Limit)).OrderBy(in.OrderBy)

stmt.WhereIf(ac.User.IsGuest(), "status = 'public'")
stmt.WhereIf(len(in.Kinds) > 0, `type in ?`, in.Kinds)
stmt.WhereIf(len(in.Kinds) > 0, `type in (?)`, in.Kinds)
stmt.WhereIf(in.ModifiedNotBefore > 0, `modified >= ?`, in.ModifiedNotBefore)
stmt.WhereIf(in.ModifiedNotAfter > 0, `modified < ?`, in.ModifiedNotAfter)

Expand Down

0 comments on commit 2caaea8

Please sign in to comment.