Skip to content

Commit 1492857

Browse files
stonezdjAYDEV-FR
authored andcommitted
Refine the sql to query non empty repositories (goharbor#22269)
use exists instead of in condition Signed-off-by: stonezdj <[email protected]>
1 parent 0813d37 commit 1492857

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pkg/repository/dao/dao.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (d *dao) NonEmptyRepos(ctx context.Context) ([]*model.RepoRecord, error) {
159159
return nil, err
160160
}
161161

162-
sql := `select * from repository where repository_id in (select distinct repository_id from tag)`
162+
sql := `select * from repository where exists (select 1 from tag where tag.repository_id = repository.repository_id)`
163163
_, err = ormer.Raw(sql).QueryRows(&repos)
164164
if err != nil {
165165
return repos, err

0 commit comments

Comments
 (0)