From b37463773ad421c5e631d9446aa42f72ef3e043c Mon Sep 17 00:00:00 2001 From: d4x1 <1507509064@qq.com> Date: Thu, 4 Jul 2024 17:33:48 +0800 Subject: [PATCH] fix(framework): case-insensitive when getting projects with keyword --- backend/server/services/project.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/server/services/project.go b/backend/server/services/project.go index 8e87d1c81b4..58ed4b17337 100644 --- a/backend/server/services/project.go +++ b/backend/server/services/project.go @@ -20,6 +20,7 @@ package services import ( "fmt" "golang.org/x/sync/errgroup" + "strings" "time" "github.com/apache/incubator-devlake/core/dal" @@ -37,7 +38,7 @@ type ProjectQuery struct { func (query *ProjectQuery) GetKeyword() string { if query != nil && query.Keyword != nil { - return *query.Keyword + return strings.ToLower(*query.Keyword) } return "" } @@ -52,7 +53,7 @@ func GetProjects(query *ProjectQuery) ([]*models.ApiOutputProject, int64, errors dal.From(&models.Project{}), } if query.Keyword != nil { - clauses = append(clauses, dal.Where("name LIKE ?", "%"+query.GetKeyword()+"%")) + clauses = append(clauses, dal.Where("LOWER(name) LIKE ?", "%"+query.GetKeyword()+"%")) } count, err := db.Count(clauses...)