Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,16 @@
"type": "boolean",
"description": "Display connections in two groups, 'Connected' and 'Not Connected'.",
"default": false
},
"sqltools.strategy": {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we make the setting name more descriptive:

Suggested change
"sqltools.strategy": {
"sqltools.connectionStore": {

"type": "string",
"enum": [
"auto",
"global",
"workspace"
],
"default": "auto",
"description": "SQLTools configuration strategy. 'auto' will use workspace settings if a workspace is open, and global settings otherwise. 'global' and 'workspace' will force the usage of global or workspace settings respectively."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"description": "SQLTools configuration strategy. 'auto' will use workspace settings if a workspace is open, and global settings otherwise. 'global' and 'workspace' will force the usage of global or workspace settings respectively."
"description": "Where SQLTools will store connections you define. 'auto' will use workspace settings if a workspace is open, and global settings otherwise. 'global' and 'workspace' will force the usage of global or workspace settings respectively."

}
}
},
Expand Down
20 changes: 18 additions & 2 deletions packages/plugins/connection-manager/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,27 @@ export class ConnectionManagerPlugin implements IExtensionPlugin {
log.warn('Nothing to do. No parameter received');
return;
}
let target: ConfigurationTarget;
const strategy = Config.strategy || 'auto';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const strategy = Config.strategy || 'auto';
const connectionStore = Config.connectionStore || 'auto';

if (!writeTo) {
switch (strategy) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
switch (strategy) {
switch (connectionStore) {

case 'global':
target = ConfigurationTarget.Global;
break;
case 'workspace':
target = ConfigurationTarget.Workspace;
break;
default:
target = workspace.workspaceFolders ? ConfigurationTarget.Workspace : ConfigurationTarget.Global;
}
} else {
target = ConfigurationTarget[writeTo];
}

const connList = this.getConnectionList(ConfigurationTarget[writeTo] || undefined);
const connList = this.getConnectionList(target || undefined);
this._throwIfNotUnique(connInfo, connList);
connList.push(connInfo);
return this.saveConnectionList(connList, ConfigurationTarget[writeTo]);
return this.saveConnectionList(connList, target);
}

private ext_updateConnection = (oldId: string, connInfo: IConnection, writeTo?: keyof typeof ConfigurationTarget) => {
Expand Down
10 changes: 10 additions & 0 deletions packages/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,16 @@ export interface ISettings {
debug?: { namespaces?: string };

'connectionExplorer.groupConnected'?: boolean;

/**
* SQLTools configuration strategy.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* SQLTools configuration strategy.
* Where SQLTools will store connections you define.

* 'auto' will use workspace settings if a workspace is open, and global settings otherwise.
* 'global' and 'workspace' will force the usage of global or workspace settings respectively.
* @type {string}
* @default 'auto'
* @memberof ISettings
*/
strategy?: 'auto' | 'global' | 'workspace';
}

export interface IConfig extends ISettings {
Expand Down