From 0f8fdec1b424fcc730f8989e77b4b75e34efab44 Mon Sep 17 00:00:00 2001 From: yasserfaraazkhan Date: Sun, 5 Apr 2026 08:56:25 +0530 Subject: [PATCH] Add LIKE support to cloud APIo --- internal/store/installation.go | 7 ++++++- internal/store/installation_test.go | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/internal/store/installation.go b/internal/store/installation.go index b99da9591..bb837ed92 100644 --- a/internal/store/installation.go +++ b/internal/store/installation.go @@ -8,6 +8,7 @@ import ( "database/sql" "encoding/json" "fmt" + "strings" sq "github.com/Masterminds/squirrel" "github.com/mattermost/mattermost-cloud/model" @@ -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) diff --git a/internal/store/installation_test.go b/internal/store/installation_test.go index 46100450b..ce633f429 100644 --- a/internal/store/installation_test.go +++ b/internal/store/installation_test.go @@ -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{