Skip to content

Commit 4f56237

Browse files
committed
Fix test
1 parent 52f64ff commit 4f56237

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

models/repo_list.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"code.gitea.io/gitea/models/unit"
1717
user_model "code.gitea.io/gitea/models/user"
1818
"code.gitea.io/gitea/modules/container"
19+
"code.gitea.io/gitea/modules/setting"
1920
"code.gitea.io/gitea/modules/structs"
2021
"code.gitea.io/gitea/modules/util"
2122

@@ -548,6 +549,20 @@ func SearchRepositoryByCondition(opts *SearchRepoOptions, cond builder.Cond, loa
548549
return repos, count, nil
549550
}
550551

552+
func withDB() *builder.Builder {
553+
switch setting.Database.Type {
554+
case "sqlite3":
555+
return builder.Dialect(builder.SQLITE)
556+
case "mysql":
557+
return builder.Dialect(builder.MYSQL)
558+
case "postgres":
559+
return builder.Dialect(builder.POSTGRES)
560+
case "mssql":
561+
return builder.Dialect(builder.MSSQL)
562+
}
563+
return &builder.Builder{}
564+
}
565+
551566
func searchRepositoryByCondition(ctx context.Context, opts *SearchRepoOptions, selCols string, cond builder.Cond) (*builder.Builder, int64, error) {
552567
if opts.Page <= 0 {
553568
opts.Page = 1
@@ -579,7 +594,7 @@ func searchRepositoryByCondition(ctx context.Context, opts *SearchRepoOptions, s
579594
orderBy = opts.OrderBy.String()
580595
}
581596

582-
b := builder.Select(selCols).From("repository").Where(cond).OrderBy(orderBy)
597+
b := withDB().Select(selCols).From("repository").Where(cond).OrderBy(orderBy)
583598
if opts.PageSize > 0 {
584599
b.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize)
585600
}

0 commit comments

Comments
 (0)