Remove redundant usage of object URNs in database commands (#24485)

This commit is contained in:
Cory Rivera
2023-09-21 11:38:44 -07:00
committed by GitHub
parent e5e535475a
commit 64337310ae
7 changed files with 20 additions and 26 deletions

View File

@@ -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.2", "version": "4.10.0.4",
"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",

View File

@@ -1649,7 +1649,6 @@ export namespace SearchObjectRequest {
export interface DetachDatabaseRequestParams { export interface DetachDatabaseRequestParams {
connectionUri: string; connectionUri: string;
database: string; database: string;
objectUrn: string;
dropConnections: boolean; dropConnections: boolean;
updateStatistics: boolean; updateStatistics: boolean;
generateScript: boolean; generateScript: boolean;
@@ -1662,7 +1661,6 @@ export namespace DetachDatabaseRequest {
export interface DropDatabaseRequestParams { export interface DropDatabaseRequestParams {
connectionUri: string; connectionUri: string;
database: string; database: string;
objectUrn: string;
dropConnections: boolean; dropConnections: boolean;
deleteBackupHistory: boolean; deleteBackupHistory: boolean;
generateScript: boolean; generateScript: boolean;
@@ -1700,13 +1698,12 @@ export namespace GetAssociatedFilesRequest {
} }
export namespace PurgeQueryStoreDataRequest { export namespace PurgeQueryStoreDataRequest {
export const type = new RequestType<purgeQueryStoreDataRequestParams, void, void, void>('objectManagement/purgeQueryStoreData'); export const type = new RequestType<PurgeQueryStoreDataRequestParams, void, void, void>('objectManagement/purgeQueryStoreData');
} }
export interface purgeQueryStoreDataRequestParams { export interface PurgeQueryStoreDataRequestParams {
connectionUri: string; connectionUri: string;
database: string; database: string;
objectUrn: string;
} }
// ------------------------------- < Object Management > ------------------------------------ // ------------------------------- < Object Management > ------------------------------------

View File

@@ -981,13 +981,12 @@ declare module 'mssql' {
* Detach a database. * Detach a database.
* @param connectionUri The URI of the server connection. * @param connectionUri The URI of the server connection.
* @param database The target database. * @param database The target database.
* @param objectUrn SMO Urn of the database to be detached. More information: https://learn.microsoft.com/sql/relational-databases/server-management-objects-smo/overview-smo
* @param dropConnections Whether to drop active connections to this database. * @param dropConnections Whether to drop active connections to this database.
* @param updateStatistics Whether to update the optimization statistics related to this database. * @param updateStatistics Whether to update the optimization statistics related to this database.
* @param generateScript Whether to generate a TSQL script for the operation instead of detaching the database. * @param generateScript Whether to generate a TSQL script for the operation instead of detaching the database.
* @returns A string value representing the generated TSQL query if generateScript was set to true, and an empty string otherwise. * @returns A string value representing the generated TSQL query if generateScript was set to true, and an empty string otherwise.
*/ */
detachDatabase(connectionUri: string, database: string, objectUrn: string, dropConnections: boolean, updateStatistics: boolean, generateScript: boolean): Thenable<string>; detachDatabase(connectionUri: string, database: string, dropConnections: boolean, updateStatistics: boolean, generateScript: boolean): Thenable<string>;
/** /**
* Attach one or more databases. * Attach one or more databases.
* @param connectionUri The URI of the server connection. * @param connectionUri The URI of the server connection.
@@ -1000,13 +999,12 @@ declare module 'mssql' {
* Drop a database. * Drop a database.
* @param connectionUri The URI of the server connection. * @param connectionUri The URI of the server connection.
* @param database The target database. * @param database The target database.
* @param objectUrn SMO Urn of the database to be detached. More information: https://learn.microsoft.com/sql/relational-databases/server-management-objects-smo/overview-smo
* @param dropConnections Whether to drop active connections to this database. * @param dropConnections Whether to drop active connections to this database.
* @param deleteBackupHistory Whether to delete backup and restore history information for this database. * @param deleteBackupHistory Whether to delete backup and restore history information for this database.
* @param generateScript Whether to generate a TSQL script for the operation instead of detaching the database. * @param generateScript Whether to generate a TSQL script for the operation instead of detaching the database.
* @returns A string value representing the generated TSQL query if generateScript was set to true, and an empty string otherwise. * @returns A string value representing the generated TSQL query if generateScript was set to true, and an empty string otherwise.
*/ */
dropDatabase(connectionUri: string, database: string, objectUrn: string, dropConnections: boolean, deleteBackupHistory: boolean, generateScript: boolean): Thenable<string>; dropDatabase(connectionUri: string, database: string, dropConnections: boolean, deleteBackupHistory: boolean, generateScript: boolean): Thenable<string>;
/** /**
* Gets the file path for the default database file folder for a SQL Server instance. * Gets the file path for the default database file folder for a SQL Server instance.
* @param connectionUri The URI of the connection for the specific server. * @param connectionUri The URI of the connection for the specific server.
@@ -1024,9 +1022,8 @@ declare module 'mssql' {
* Clears all query store data from the database * Clears all query store data from the database
* @param connectionUri The URI of the server connection. * @param connectionUri The URI of the server connection.
* @param database The target database. * @param database The target database.
* @param objectUrn SMO Urn of the database to be detached. More information: https://learn.microsoft.com/sql/relational-databases/server-management-objects-smo/overview-smo
*/ */
purgeQueryStoreData(connectionUri: string, database: string, objectUrn: string): Thenable<void>; purgeQueryStoreData(connectionUri: string, database: string): Thenable<void>;
} }
export interface DatabaseFileData { export interface DatabaseFileData {

View File

@@ -66,13 +66,13 @@ export class ObjectManagementService extends BaseService implements IObjectManag
return this.runWithErrorHandling(contracts.SearchObjectRequest.type, params); return this.runWithErrorHandling(contracts.SearchObjectRequest.type, params);
} }
async detachDatabase(connectionUri: string, database: string, objectUrn: string, dropConnections: boolean, updateStatistics: boolean, generateScript: boolean): Promise<string> { async detachDatabase(connectionUri: string, database: string, dropConnections: boolean, updateStatistics: boolean, generateScript: boolean): Promise<string> {
const params: contracts.DetachDatabaseRequestParams = { connectionUri, database, objectUrn, dropConnections, updateStatistics, generateScript }; const params: contracts.DetachDatabaseRequestParams = { connectionUri, database, dropConnections, updateStatistics, generateScript };
return this.runWithErrorHandling(contracts.DetachDatabaseRequest.type, params); return this.runWithErrorHandling(contracts.DetachDatabaseRequest.type, params);
} }
async dropDatabase(connectionUri: string, database: string, objectUrn: string, dropConnections: boolean, deleteBackupHistory: boolean, generateScript: boolean): Promise<string> { async dropDatabase(connectionUri: string, database: string, dropConnections: boolean, deleteBackupHistory: boolean, generateScript: boolean): Promise<string> {
const params: contracts.DropDatabaseRequestParams = { connectionUri, database, objectUrn, dropConnections, deleteBackupHistory, generateScript }; const params: contracts.DropDatabaseRequestParams = { connectionUri, database, dropConnections, deleteBackupHistory, generateScript };
return this.runWithErrorHandling(contracts.DropDatabaseRequest.type, params); return this.runWithErrorHandling(contracts.DropDatabaseRequest.type, params);
} }
@@ -91,8 +91,8 @@ export class ObjectManagementService extends BaseService implements IObjectManag
return this.runWithErrorHandling(contracts.GetAssociatedFilesRequest.type, params); return this.runWithErrorHandling(contracts.GetAssociatedFilesRequest.type, params);
} }
async purgeQueryStoreData(connectionUri: string, database: string, objectUrn: string): Promise<void> { async purgeQueryStoreData(connectionUri: string, database: string): Promise<void> {
const params: contracts.purgeQueryStoreDataRequestParams = { connectionUri, database, objectUrn }; const params: contracts.PurgeQueryStoreDataRequestParams = { connectionUri, database };
return this.runWithErrorHandling(contracts.PurgeQueryStoreDataRequest.type, params); return this.runWithErrorHandling(contracts.PurgeQueryStoreDataRequest.type, params);
} }
} }
@@ -262,7 +262,7 @@ export class TestObjectManagementService implements IObjectManagementService {
return this.delayAndResolve(items); return this.delayAndResolve(items);
} }
async detachDatabase(connectionUri: string, database: string, objectUrn: string, dropConnections: boolean, updateStatistics: boolean, generateScript: boolean): Promise<string> { async detachDatabase(connectionUri: string, database: string, dropConnections: boolean, updateStatistics: boolean, generateScript: boolean): Promise<string> {
return this.delayAndResolve(''); return this.delayAndResolve('');
} }
@@ -270,7 +270,7 @@ export class TestObjectManagementService implements IObjectManagementService {
return this.delayAndResolve(''); return this.delayAndResolve('');
} }
dropDatabase(connectionUri: string, database: string, objectUrn: string, dropConnections: boolean, deleteBackupHistory: boolean, generateScript: boolean): Thenable<string> { dropDatabase(connectionUri: string, database: string, dropConnections: boolean, deleteBackupHistory: boolean, generateScript: boolean): Thenable<string> {
return this.delayAndResolve(''); return this.delayAndResolve('');
} }
@@ -282,7 +282,7 @@ export class TestObjectManagementService implements IObjectManagementService {
return this.delayAndResolve([]); return this.delayAndResolve([]);
} }
async purgeQueryStoreData(connectionUri: string, database: string, objectUrn: string): Promise<void> { async purgeQueryStoreData(connectionUri: string, database: string): Promise<void> {
return this.delayAndResolve([]); return this.delayAndResolve([]);
} }

View File

@@ -1848,7 +1848,7 @@ export class DatabaseDialog extends ObjectManagementDialogBase<Database, Databas
return; return;
} }
await this.objectManagementService.purgeQueryStoreData(this.options.connectionUri, this.options.database, this.options.objectUrn); await this.objectManagementService.purgeQueryStoreData(this.options.connectionUri, this.options.database);
} }
private async toggleQueryStoreOptions(): Promise<void> { private async toggleQueryStoreOptions(): Promise<void> {

View File

@@ -49,11 +49,11 @@ export class DetachDatabaseDialog extends ObjectManagementDialogBase<Database, D
} }
protected override async saveChanges(contextId: string, object: ObjectManagement.SqlObject): Promise<void> { protected override async saveChanges(contextId: string, object: ObjectManagement.SqlObject): Promise<void> {
await this.objectManagementService.detachDatabase(this.options.connectionUri, this.options.database, this.options.objectUrn, this._dropConnections, this._updateStatistics, false); await this.objectManagementService.detachDatabase(this.options.connectionUri, this.options.database, this._dropConnections, this._updateStatistics, false);
} }
protected override async generateScript(): Promise<string> { protected override async generateScript(): Promise<string> {
return await this.objectManagementService.detachDatabase(this.options.connectionUri, this.options.database, this.options.objectUrn, this._dropConnections, this._updateStatistics, true); return await this.objectManagementService.detachDatabase(this.options.connectionUri, this.options.database, this._dropConnections, this._updateStatistics, true);
} }
protected override async validateInput(): Promise<string[]> { protected override async validateInput(): Promise<string[]> {

View File

@@ -53,11 +53,11 @@ export class DropDatabaseDialog extends ObjectManagementDialogBase<Database, Dat
} }
protected override async saveChanges(contextId: string, object: ObjectManagement.SqlObject): Promise<void> { protected override async saveChanges(contextId: string, object: ObjectManagement.SqlObject): Promise<void> {
await this.objectManagementService.dropDatabase(this.options.connectionUri, this.options.database, this.options.objectUrn, this._dropConnections, this._deleteBackupHistory, false); await this.objectManagementService.dropDatabase(this.options.connectionUri, this.options.database, this._dropConnections, this._deleteBackupHistory, false);
} }
protected override async generateScript(): Promise<string> { protected override async generateScript(): Promise<string> {
return await this.objectManagementService.dropDatabase(this.options.connectionUri, this.options.database, this.options.objectUrn, this._dropConnections, this._deleteBackupHistory, true); return await this.objectManagementService.dropDatabase(this.options.connectionUri, this.options.database, this._dropConnections, this._deleteBackupHistory, true);
} }
protected override async validateInput(): Promise<string[]> { protected override async validateInput(): Promise<string[]> {