Skip to content

Commit

Permalink
fix(server): fix environments search query (#2956)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeepc committed Jul 17, 2023
1 parent 5e422d9 commit e6f6ba3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/environment/environment_repository.go
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

0 comments on commit e6f6ba3

Please sign in to comment.