diff --git a/internal/store/database/pipeline.go b/internal/store/database/pipeline.go index 9ac2aaaf7..0aa333ead 100644 --- a/internal/store/database/pipeline.go +++ b/internal/store/database/pipeline.go @@ -239,7 +239,7 @@ func (s *pipelineStore) Count(ctx context.Context, parentID int64, filter types. Where("pipeline_space_id = ?", parentID) if filter.Query != "" { - stmt = stmt.Where("pipeline_uid LIKE ?", fmt.Sprintf("%%%s%%", filter.Query)) + stmt = stmt.Where("LOWER(pipeline_uid) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(filter.Query))) } sql, args, err := stmt.ToSql() diff --git a/internal/store/database/pullreq.go b/internal/store/database/pullreq.go index eab7003b2..1d837faec 100644 --- a/internal/store/database/pullreq.go +++ b/internal/store/database/pullreq.go @@ -407,6 +407,10 @@ func (s *PullReqStore) Count(ctx context.Context, opts *types.PullReqFilter) (in stmt = stmt.Where("pullreq_target_branch = ?", opts.TargetBranch) } + if opts.Query != "" { + stmt = stmt.Where("LOWER(pullreq_title) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(opts.Query))) + } + if opts.CreatedBy != 0 { stmt = stmt.Where("pullreq_created_by = ?", opts.CreatedBy) } @@ -459,7 +463,7 @@ func (s *PullReqStore) List(ctx context.Context, opts *types.PullReqFilter) ([]* stmt = stmt.Where("LOWER(pullreq_title) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(opts.Query))) } - if opts.CreatedBy > 0 { + if opts.CreatedBy != 0 { stmt = stmt.Where("pullreq_created_by = ?", opts.CreatedBy) } diff --git a/internal/store/database/repo.go b/internal/store/database/repo.go index 85a6898c3..30b9b20d7 100644 --- a/internal/store/database/repo.go +++ b/internal/store/database/repo.go @@ -257,7 +257,7 @@ func (s *RepoStore) Count(ctx context.Context, parentID int64, opts *types.RepoF Where("repo_parent_id = ?", parentID) if opts.Query != "" { - stmt = stmt.Where("repo_uid LIKE ?", fmt.Sprintf("%%%s%%", opts.Query)) + stmt = stmt.Where("LOWER(repo_uid) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(opts.Query))) } sql, args, err := stmt.ToSql() diff --git a/internal/store/database/secret.go b/internal/store/database/secret.go index 8ade23d57..ac2b04c46 100644 --- a/internal/store/database/secret.go +++ b/internal/store/database/secret.go @@ -247,7 +247,7 @@ func (s *secretStore) Count(ctx context.Context, parentID int64, filter types.Li Where("secret_space_id = ?", parentID) if filter.Query != "" { - stmt = stmt.Where("secret_uid LIKE ?", fmt.Sprintf("%%%s%%", filter.Query)) + stmt = stmt.Where("LOWER(secret_uid) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(filter.Query))) } sql, args, err := stmt.ToSql() diff --git a/internal/store/database/webhook.go b/internal/store/database/webhook.go index f5754b1a4..f05e1c230 100644 --- a/internal/store/database/webhook.go +++ b/internal/store/database/webhook.go @@ -264,6 +264,10 @@ func (s *WebhookStore) Count(ctx context.Context, parentType enum.WebhookParent, return 0, fmt.Errorf("webhook parent type '%s' is not supported", parentType) } + if opts.Query != "" { + stmt = stmt.Where("LOWER(webhook_display_name) LIKE ?", fmt.Sprintf("%%%s%%", strings.ToLower(opts.Query))) + } + sql, args, err := stmt.ToSql() if err != nil { return 0, fmt.Errorf("failed to convert query to sql: %w", err)