loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix Operator does not exist bug on explore page with ONLY_SHOW_RELEVANT_REPOS (#22454)

There is a mistake in the code for SearchRepositoryCondition where it
tests topics as a string. This is incorrect for postgres where topics is
cast and stored as json. topics needs to be cast to text for this to
work. (For some reason JSON_ARRAY_LENGTH does not work, so I have taken
the simplest solution of casting to text and doing a string comparison.)

Ref https://github.com/go-gitea/gitea/pull/21962#issuecomment-1379584057

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>

authored by

zeripath
delvh
and committed by
GitHub
16e9dec8 1e7f3c16

+7 -2
+7 -2
models/repo/repo_list.go
··· 13 13 "code.gitea.io/gitea/models/unit" 14 14 user_model "code.gitea.io/gitea/models/user" 15 15 "code.gitea.io/gitea/modules/container" 16 + "code.gitea.io/gitea/modules/setting" 16 17 "code.gitea.io/gitea/modules/structs" 17 18 "code.gitea.io/gitea/modules/util" 18 19 ··· 496 497 // Only show a repo that either has a topic or description. 497 498 subQueryCond := builder.NewCond() 498 499 499 - // Topic checking. Topics is non-null. 500 - subQueryCond = subQueryCond.Or(builder.And(builder.Neq{"topics": "null"}, builder.Neq{"topics": "[]"})) 500 + // Topic checking. Topics are present. 501 + if setting.Database.UsePostgreSQL { // postgres stores the topics as json and not as text 502 + subQueryCond = subQueryCond.Or(builder.And(builder.NotNull{"topics"}, builder.Neq{"(topics)::text": "[]"})) 503 + } else { 504 + subQueryCond = subQueryCond.Or(builder.And(builder.Neq{"topics": "null"}, builder.Neq{"topics": "[]"})) 505 + } 501 506 502 507 // Description checking. Description not empty. 503 508 subQueryCond = subQueryCond.Or(builder.Neq{"description": ""})