From 3a15d38c452414d1be9a333899c2d60f323ab3a6 Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Tue, 17 Mar 2026 08:40:29 -0400 Subject: [PATCH] Fix database picker not changing query editor context (#92) Rebuild connection string from current database selection at execution time rather than relying on cached _connectionString from SelectionChanged. Guarantees the picker state is always reflected when running queries. Closes #92 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/PlanViewer.App/Controls/QuerySessionControl.axaml.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PlanViewer.App/Controls/QuerySessionControl.axaml.cs b/src/PlanViewer.App/Controls/QuerySessionControl.axaml.cs index 07cd369..8a90a2e 100644 --- a/src/PlanViewer.App/Controls/QuerySessionControl.axaml.cs +++ b/src/PlanViewer.App/Controls/QuerySessionControl.axaml.cs @@ -495,12 +495,16 @@ private async void ExecuteEstimated_Click(object? sender, RoutedEventArgs e) private async Task CaptureAndShowPlan(bool estimated, string? queryTextOverride = null) { - if (_connectionString == null || _selectedDatabase == null) + if (_serverConnection == null || _selectedDatabase == null) { SetStatus("Connect to a server first", autoClear: false); return; } + // Always rebuild connection string from current database selection + // to guarantee the picker state is reflected at execution time + _connectionString = _serverConnection.GetConnectionString(_credentialService, _selectedDatabase); + var queryText = queryTextOverride?.Trim() ?? GetSelectedTextOrNull()?.Trim() ?? QueryEditor.Text?.Trim();