mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Transfer URI Correctly (#24614)
* transfer uri regardless of queryrunner presence * throw error if new URI already exists * bump sts version
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
||||||
"version": "4.10.0.14",
|
"version": "4.10.0.15",
|
||||||
"downloadFileNames": {
|
"downloadFileNames": {
|
||||||
"Windows_86": "win-x86-net7.0.zip",
|
"Windows_86": "win-x86-net7.0.zip",
|
||||||
"Windows_64": "win-x64-net7.0.zip",
|
"Windows_64": "win-x64-net7.0.zip",
|
||||||
|
|||||||
@@ -339,16 +339,16 @@ export class QueryManagementService implements IQueryManagementService {
|
|||||||
let item = this._queryRunners.get(oldUri);
|
let item = this._queryRunners.get(oldUri);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
this._logService.error(`No query runner found for old URI : '${oldUri}'`);
|
this._logService.error(`No query runner found for old URI : '${oldUri}'`);
|
||||||
throw new Error(nls.localize('queryManagement.noQueryRunnerForUri', 'Could not find Query Runner for uri: {0}', oldUri));
|
} else if (this._queryRunners.get(newUri)) {
|
||||||
}
|
|
||||||
if (this._queryRunners.get(newUri)) {
|
|
||||||
this._logService.error(`New URI : '${newUri}' already has a query runner.`);
|
this._logService.error(`New URI : '${newUri}' already has a query runner.`);
|
||||||
throw new Error(nls.localize('queryManagement.uriAlreadyHasQueryRunner', 'Uri: {0} unexpectedly already has a query runner.', newUri));
|
throw new Error(nls.localize('queryManagement.uriAlreadyHasQueryRunner', 'Uri: {0} unexpectedly already has a query runner.', newUri));
|
||||||
|
} else {
|
||||||
|
this._queryRunners.set(newUri, item);
|
||||||
|
this._queryRunners.delete(oldUri);
|
||||||
}
|
}
|
||||||
this._queryRunners.set(newUri, item);
|
|
||||||
this._queryRunners.delete(oldUri);
|
return this._runAction(newUri, (handler) => {
|
||||||
return this._runAction(newUri, (runner) => {
|
return handler.connectionUriChanged(newUri, oldUri);
|
||||||
return runner.connectionUriChanged(newUri, oldUri);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import Severity from 'vs/base/common/severity';
|
|||||||
import EditQueryRunner from 'sql/workbench/services/editData/common/editQueryRunner';
|
import EditQueryRunner from 'sql/workbench/services/editData/common/editQueryRunner';
|
||||||
import { IRange } from 'vs/editor/common/core/range';
|
import { IRange } from 'vs/editor/common/core/range';
|
||||||
import { ClipboardData, IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
import { ClipboardData, IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||||
|
import { IQueryManagementService } from 'sql/workbench/services/query/common/queryManagement';
|
||||||
|
|
||||||
const selectionSnippetMaxLen = 100;
|
const selectionSnippetMaxLen = 100;
|
||||||
|
|
||||||
@@ -81,6 +82,7 @@ export class QueryModelService implements IQueryModelService {
|
|||||||
|
|
||||||
// CONSTRUCTOR /////////////////////////////////////////////////////////
|
// CONSTRUCTOR /////////////////////////////////////////////////////////
|
||||||
constructor(
|
constructor(
|
||||||
|
@IQueryManagementService protected queryManagementService: IQueryManagementService,
|
||||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||||
@INotificationService private _notificationService: INotificationService,
|
@INotificationService private _notificationService: INotificationService,
|
||||||
@IClipboardService private _clipboardService: IClipboardService,
|
@IClipboardService private _clipboardService: IClipboardService,
|
||||||
@@ -437,21 +439,17 @@ export class QueryModelService implements IQueryModelService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async changeConnectionUri(newUri: string, oldUri: string): Promise<void> {
|
public async changeConnectionUri(newUri: string, oldUri: string): Promise<void> {
|
||||||
// Get existing query runner
|
if (this._queryInfoMap.has(newUri)) {
|
||||||
let queryRunner = this.internalGetQueryRunner(oldUri);
|
|
||||||
if (!queryRunner) {
|
|
||||||
// Nothing to do if we don't have a query runner currently (no connection)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (this._queryInfoMap.has(newUri)) {
|
|
||||||
this._logService.error(`New URI '${newUri}' already has query info associated with it.`);
|
this._logService.error(`New URI '${newUri}' already has query info associated with it.`);
|
||||||
throw new Error(nls.localize('queryModelService.uriAlreadyHasQuery', '{0} already has an existing query', newUri));
|
throw new Error(nls.localize('queryModelService.uriAlreadyHasQuery', '{0} already has an existing query', newUri));
|
||||||
}
|
}
|
||||||
|
await this.queryManagementService.changeConnectionUri(newUri, oldUri);
|
||||||
|
|
||||||
await queryRunner.changeConnectionUri(newUri, oldUri);
|
// remove the old key and set new key with same query info as old uri.
|
||||||
|
|
||||||
// remove the old key and set new key with same query info as old uri. (Info existence is checked in internalGetQueryRunner)
|
|
||||||
let info = this._queryInfoMap.get(oldUri);
|
let info = this._queryInfoMap.get(oldUri);
|
||||||
|
if (!info) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
info.uri = newUri;
|
info.uri = newUri;
|
||||||
this._queryInfoMap.set(newUri, info);
|
this._queryInfoMap.set(newUri, info);
|
||||||
this._queryInfoMap.delete(oldUri);
|
this._queryInfoMap.delete(oldUri);
|
||||||
|
|||||||
@@ -468,10 +468,6 @@ export default class QueryRunner extends Disposable {
|
|||||||
this._isDisposed = true;
|
this._isDisposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public changeConnectionUri(oldUri: string, newUri: string): Promise<void> {
|
|
||||||
return this.queryManagementService.changeConnectionUri(oldUri, newUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
get totalElapsedMilliseconds(): number {
|
get totalElapsedMilliseconds(): number {
|
||||||
return this._totalElapsedMilliseconds;
|
return this._totalElapsedMilliseconds;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user