Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion internal/store/installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
"strings"

sq "github.com/Masterminds/squirrel"
"github.com/mattermost/mattermost-cloud/model"
Expand Down Expand Up @@ -191,7 +192,11 @@ func (sqlStore *SQLStore) applyInstallationFilter(builder sq.SelectBuilder, filt
builder = builder.Where("State = ?", filter.State)
}
if filter.DNS != "" {
builder = builder.Where("InstallationDNS.DomainName = ?", filter.DNS)
if strings.Contains(filter.DNS, "%") {
builder = builder.Where("InstallationDNS.DomainName LIKE ?", filter.DNS)
} else {
builder = builder.Where("InstallationDNS.DomainName = ?", filter.DNS)
}
}
if filter.Name != "" {
builder = builder.Where("Installation.Name = ?", filter.Name)
Expand Down
16 changes: 16 additions & 0 deletions internal/store/installation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,22 @@ func TestInstallations(t *testing.T) {
},
[]*model.Installation{installation3},
},
{
"dns LIKE pattern",
&model.InstallationFilter{
DNS: "dns-%",
Paging: model.AllPagesNotDeleted(),
},
[]*model.Installation{installation1, installation2, installation3},
},
{
"dns LIKE pattern no match",
&model.InstallationFilter{
DNS: "nonexistent-%",
Paging: model.AllPagesNotDeleted(),
},
nil,
},
{
"state stable",
&model.InstallationFilter{
Expand Down
Loading