Skip to content

Persist initial database name on saved connection updates (#358)#360

Merged
erikdarlingdata merged 1 commit into
devfrom
fix/persist-initial-database-358
Jun 9, 2026
Merged

Persist initial database name on saved connection updates (#358)#360
erikdarlingdata merged 1 commit into
devfrom
fix/persist-initial-database-358

Conversation

@erikdarlingdata

Copy link
Copy Markdown
Owner

Summary

Fixes the reopened follow-up on #358: when reconnecting to a previously used server, the new Initial database field came back empty even though server name and credentials were remembered.

Root cause

#359 added the field and was meant to persist it on ServerConnectionBuildServerConnection sets it and ApplySavedConnection restores it. But ConnectionStore.AddOrUpdate silently dropped it: the update branch copies fields onto the existing record one at a time and never assigned DatabaseName. So the field was only saved on the first connect to a brand-new server (the add branch persists the whole object) and discarded on every reconnect to a known server.

Benjamin's Azure/JIT server already existed in his connections.json from before #359, so his connect always took the update path — which is why the field never stuck for him. The same bug also meant a saved server could never have its initial database changed.

Fix

One line in the update branch of AddOrUpdate:

existing.DatabaseName = connection.DatabaseName;

The restore side (ApplySavedConnection) already pre-fills the field, so this closes the loop.

Test plan

  • dotnet build src/PlanViewer.App succeeds
  • Connect to an already-saved server with an Initial database typed in → reopen the dialog → field is pre-filled
  • Change the Initial database on a saved server, reconnect, reopen → new value is retained

🤖 Generated with Claude Code

PR #359 added an optional "Initial database" field to the Connect dialog
and was meant to persist it on ServerConnection. BuildServerConnection set
it and ApplySavedConnection restored it, but ConnectionStore.AddOrUpdate
dropped it: the update branch copies fields onto the existing record one by
one and never assigned DatabaseName. So the field was only saved on the very
first connect to a brand-new server (the add branch persists the whole
object) and silently discarded on every reconnect to a known server.

That is exactly the reopened follow-up on #358: reconnecting to a previously
used server left the Initial database field empty even though server name and
credentials were remembered. It also meant a saved server could never have
its initial database changed.

Assign existing.DatabaseName from the incoming connection in the update
branch so the field round-trips on every save.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 2b334f1 into dev Jun 9, 2026
2 checks passed
@erikdarlingdata erikdarlingdata deleted the fix/persist-initial-database-358 branch June 9, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant