Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): fix environments search query #2956

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions server/environment/environment_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (r *Repository) Delete(ctx context.Context, id id.ID) error {

func listQuery(baseSQL, query string, params []any) (string, []any) {
paramNumber := len(params) + 1
condition := fmt.Sprintf(" AND (t.name ilike $%d OR e.description ilike $%d)", paramNumber, paramNumber)
condition := fmt.Sprintf(" WHERE (e.name ilike $%d OR e.description ilike $%d)", paramNumber, paramNumber)

sql, params := sqlutil.Search(baseSQL, condition, query, params)

Expand Down Expand Up @@ -249,7 +249,8 @@ func (r *Repository) countEnvironments(ctx context.Context, query string) (int,
params []any
)

sql := countQuery + query
condition := " WHERE (e.name ilike $1 OR e.description ilike $1)"
sql, params := sqlutil.Search(countQuery, condition, query, params)

err := r.db.
QueryRowContext(ctx, sql, params...).
Expand Down