From 111db6fc872f65e69b11daad609142db0e41af00 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 Aug 2025 23:07:15 +0000 Subject: [PATCH] Add validation tests for query optimizations Co-authored-by: muhlemmer <5411563+muhlemmer@users.noreply.github.com> --- internal/query/introspection_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/query/introspection_test.go b/internal/query/introspection_test.go index 92c571ebf9..ba88ff0984 100644 --- a/internal/query/introspection_test.go +++ b/internal/query/introspection_test.go @@ -102,3 +102,19 @@ func TestQueries_ActiveIntrospectionClientByID(t *testing.T) { }) } } + +// TestIntrospectionQueryOptimizations validates that the optimized query +// has the expected performance characteristics +func TestIntrospectionQueryOptimizations(t *testing.T) { + // Test that UNION ALL is used instead of UNION + assert.Contains(t, introspectionClientByIDQuery, "union all", "Expected 'union all' in optimized query") + + // Test that aliases are used consistently + assert.Contains(t, introspectionClientByIDQuery, "from config c", "Expected consistent alias usage 'config c'") + + // Test that keys CTE is simplified + assert.Contains(t, introspectionClientByIDQuery, "$2::text as client_id", "Expected simplified keys CTE with $2::text casting") + + // Test that conditional join logic is present + assert.Contains(t, introspectionClientByIDQuery, "and $3 = true", "Expected conditional join logic 'and $3 = true'") +}