Skip to content

fix(server): reset connection settings on switch and resolve the project root from rootUri - #265

Merged
joe-re merged 1 commit into
releasefrom
fix/setting-store-and-root-path
Sep 27, 2026
Merged

joe-re merged 1 commit into
releasefrom
fix/setting-store-and-root-path

Conversation

@joe-re

@joe-re joe-re commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes two server bugs found while testing the modernization PRs, plus a related one.

1. Switching connections kept fields of the previous connection

SettingStore.setSetting did Object.assign({}, this.state, newSetting), so fields the new connection does not define (database, host, port, ...) leaked from the previous one. For example, after switching mysql -> sqlite, sqlite tables were offered as mysql_db.users. The new connection now replaces the whole setting (starting from the default state).

An existing test (setSettingFromWorkspaceConfig) expected database: 'projectConfigDatabase', a value that only exists in the project config file of an earlier test. It only passed because of this leak, so its expectation is corrected.

2. Project config was not loaded for clients that don't send rootPath

The server read only the deprecated InitializeParams.rootPath. It now resolves the project root from the first workspaceFolders entry, then rootUri, then rootPath (resolveRootPath.ts). Non-file: URIs are ignored.

3. projectPaths was ignored for workspace-configured connections

setSettingFromWorkspaceConfig was always called without the project path, so connections from the sqlLanguageServer.connections setting never matched projectPaths and the first one was always used. The resolved root is now passed.

Test plan

  • New test "should not keep fields of the previous connection" fails on release and passes with the fix
  • New resolveRootPath tests (workspaceFolders > rootUri > rootPath, URI decoding, non-file URIs)
  • LSP session over stdio with only rootUri, and with only workspaceFolders: the project's .sqllsrc.json (sqlite) is loaded and its table appears in completion. With the release build, neither case loads it.
  • build / lint / typecheck / all tests (server 128 passed)

…ect root from rootUri

- SettingStore.setSetting merged the new connection into the previous
  state, so fields the new connection does not set (database, host, ...)
  leaked from the old one. Start from the default state instead. An existing
  test only passed because of this leak.
- Resolve the project root from workspaceFolders, then rootUri, then the
  deprecated rootPath. Clients that send only rootUri / workspaceFolders did
  not get the project .sqllsrc.json loaded.
- Pass the project root to setSettingFromWorkspaceConfig so projectPaths are
  matched for connections given through the workspace configuration.
@joe-re
joe-re merged commit 40da89f into release Sep 27, 2026
5 checks passed
@joe-re
joe-re deleted the fix/setting-store-and-root-path branch September 27, 2026 21:15
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