@@ -16,6 +16,7 @@ import (
16
16
"code.gitea.io/gitea/models/unit"
17
17
user_model "code.gitea.io/gitea/models/user"
18
18
"code.gitea.io/gitea/modules/container"
19
+ "code.gitea.io/gitea/modules/setting"
19
20
"code.gitea.io/gitea/modules/structs"
20
21
"code.gitea.io/gitea/modules/util"
21
22
@@ -548,6 +549,20 @@ func SearchRepositoryByCondition(opts *SearchRepoOptions, cond builder.Cond, loa
548
549
return repos , count , nil
549
550
}
550
551
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
+
551
566
func searchRepositoryByCondition (ctx context.Context , opts * SearchRepoOptions , selCols string , cond builder.Cond ) (* builder.Builder , int64 , error ) {
552
567
if opts .Page <= 0 {
553
568
opts .Page = 1
@@ -579,7 +594,7 @@ func searchRepositoryByCondition(ctx context.Context, opts *SearchRepoOptions, s
579
594
orderBy = opts .OrderBy .String ()
580
595
}
581
596
582
- b := builder .Select (selCols ).From ("repository" ).Where (cond ).OrderBy (orderBy )
597
+ b := withDB () .Select (selCols ).From ("repository" ).Where (cond ).OrderBy (orderBy )
583
598
if opts .PageSize > 0 {
584
599
b .Limit (opts .PageSize , (opts .Page - 1 )* opts .PageSize )
585
600
}
0 commit comments