From b3ff359fc162353d8174a44ef29aa0685aa0ce94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Tue, 7 Nov 2023 08:12:16 +0200 Subject: [PATCH] fix(system-api): use distinct in intances filter query (#6867) --- internal/query/instance.go | 2 +- internal/query/instance_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/query/instance.go b/internal/query/instance.go index 8a683d7f26..ba28bb6a24 100644 --- a/internal/query/instance.go +++ b/internal/query/instance.go @@ -291,7 +291,7 @@ func prepareInstancesQuery(ctx context.Context, db prepareDatabase) (sq.SelectBu return sq.Select( InstanceColumnID.identifier(), countColumn.identifier(), - ).From(instanceTable.identifier()). + ).Distinct().From(instanceTable.identifier()). LeftJoin(join(InstanceDomainInstanceIDCol, InstanceColumnID)), func(builder sq.SelectBuilder) sq.SelectBuilder { return sq.Select( diff --git a/internal/query/instance_test.go b/internal/query/instance_test.go index 27e206e0ee..decd687e29 100644 --- a/internal/query/instance_test.go +++ b/internal/query/instance_test.go @@ -55,7 +55,7 @@ var ( ` projections.instance_domains.creation_date,` + ` projections.instance_domains.change_date, ` + ` projections.instance_domains.sequence` + - ` FROM (SELECT projections.instances.id, COUNT(*) OVER () FROM projections.instances` + + ` FROM (SELECT DISTINCT projections.instances.id, COUNT(*) OVER () FROM projections.instances` + ` LEFT JOIN projections.instance_domains ON projections.instances.id = projections.instance_domains.instance_id) AS f` + ` LEFT JOIN projections.instances ON f.id = projections.instances.id` + ` LEFT JOIN projections.instance_domains ON f.id = projections.instance_domains.instance_id` +