A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix: change from xorm builder union query to manual build query
kumfo7bea814bd410
diff --git a/internal/repo/search_common/search_repo.go b/internal/repo/search_common/search_repo.goindex b2db83c3..72965c1f 100644--- a/internal/repo/search_common/search_repo.go+++ b/internal/repo/search_common/search_repo.go@@ -142,13 +142,22 @@ func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagID,argsA = append(argsA, votes)}- b = b.Union("all", ub)+ //b = b.Union("all", ub)+ ubSQL, _, err := ub.ToSQL()+ if err != nil {+ return+ }+ bSQL, _, err := b.ToSQL()+ if err != nil {+ return+ }+ sql := fmt.Sprintf("(%s UNION ALL %s)", ubSQL, bSQL)- querySQL, _, err := builder.MySQL().Select("*").From(b, "t").OrderBy(sr.parseOrder(ctx, order)).Limit(size, page-1).ToSQL()+ querySQL, _, err := builder.MySQL().Select("*").From(sql, "t").OrderBy(sr.parseOrder(ctx, order)).Limit(size, page-1).ToSQL()if err != nil {return}- countSQL, _, err := builder.MySQL().Select("count(*) total").From(b, "c").ToSQL()+ countSQL, _, err := builder.MySQL().Select("count(*) total").From(sql, "c").ToSQL()if err != nil {return}