Repository navigation
fix(server): reset connection settings on switch and resolve the project root from rootUri - #265
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.setSettingdidObject.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 asmysql_db.users. The new connection now replaces the whole setting (starting from the default state).An existing test (
setSettingFromWorkspaceConfig) expecteddatabase: '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
rootPathThe server read only the deprecated
InitializeParams.rootPath. It now resolves the project root from the firstworkspaceFoldersentry, thenrootUri, thenrootPath(resolveRootPath.ts). Non-file:URIs are ignored.3.
projectPathswas ignored for workspace-configured connectionssetSettingFromWorkspaceConfigwas always called without the project path, so connections from thesqlLanguageServer.connectionssetting never matchedprojectPathsand the first one was always used. The resolved root is now passed.Test plan
releaseand passes with the fixresolveRootPathtests (workspaceFolders > rootUri > rootPath, URI decoding, non-file URIs)rootUri, and with onlyworkspaceFolders: the project's.sqllsrc.json(sqlite) is loaded and its table appears in completion. With thereleasebuild, neither case loads it.