Fixing rename databases#21899
Conversation
- Introduced a new webview for renaming databases, including a dialog page and form. - Implemented the RenameDatabaseWebviewController to handle the renaming logic. - Added constants and localization for the rename database feature. - Created SVG icons for the rename database action. - Updated the object management service to support renaming databases. - Added tests for the new rename database functionality, ensuring correct request handling and error management.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new Rename Database webview workflow so users can rename databases (optionally dropping active connections) and generate scripts, replacing the previous inline input-box flow that could get stuck when connections exist.
Changes:
- Introduces a new Rename Database object-management webview (UI, controller, bundling, icons, localization).
- Adds a new SQL Tools contract + service method for rename-database operations and wires it into the main controller command.
- Adds unit tests for the new controller flow and the service request payload.
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| localization/xliff/vscode-mssql.xlf | Adds new localized strings used by the rename-database UI. |
| extensions/mssql/test/unit/renameDatabaseWebviewController.test.ts | New unit tests covering controller initialization, submit, script, and error paths. |
| extensions/mssql/test/unit/objectManagementService.test.ts | Adds a unit test validating the rename-database request contract and parameters. |
| extensions/mssql/src/webviews/pages/ObjectManagement/renameDatabaseIndex.tsx | New webview entrypoint wiring providers and the rename page. |
| extensions/mssql/src/webviews/pages/ObjectManagement/renameDatabaseForm.tsx | New form UI for rename options and database details. |
| extensions/mssql/src/webviews/pages/ObjectManagement/renameDatabaseDialogPage.tsx | New dialog page implementing validation and RPC actions (submit/script/help/cancel). |
| extensions/mssql/src/webviews/common/locConstants.ts | Adds localized strings for the rename database webview. |
| extensions/mssql/src/webviews/common/icons/renameDatabase.tsx | Adds a new icon component for the rename database dialog. |
| extensions/mssql/src/sharedInterfaces/objectManagement.ts | Extends shared object-management interfaces to support rename database dialog/types. |
| extensions/mssql/src/services/objectManagementService.ts | Adds renameDatabase and adjusts initializeView signature. |
| extensions/mssql/src/models/contracts/objectManagement.ts | Introduces RenameDatabaseRequest contract for SQL Tools RPC. |
| extensions/mssql/src/controllers/renameDatabaseWebviewController.ts | New controller managing the rename database webview lifecycle and actions. |
| extensions/mssql/src/controllers/mainController.ts | Replaces old rename flow with new rename webview controller integration. |
| extensions/mssql/src/constants/locConstants.ts | Adds a rename database webview title constant. |
| extensions/mssql/src/constants/constants.ts | Adds a help link for rename database. |
| extensions/mssql/scripts/bundle-webviews.js | Bundles the new rename database webview entrypoint. |
| extensions/mssql/media/renameDatabase_light.svg | Adds light-theme SVG asset for the rename dialog. |
| extensions/mssql/media/renameDatabase_dark.svg | Adds dark-theme SVG asset for the rename dialog. |
| extensions/mssql/l10n/bundle.l10n.json | Adds localized strings for the new rename database webview. |
PR Changes
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #21899 +/- ##
==========================================
+ Coverage 74.65% 74.70% +0.04%
==========================================
Files 392 393 +1
Lines 117355 117667 +312
Branches 6710 6728 +18
==========================================
+ Hits 87617 87907 +290
- Misses 29738 29760 +22
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <[email protected]>
…riable naming and improve error handling in save and drop operations Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 25 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (3)
extensions/mssql/test/unit/objectManagementService.test.ts:91
- These tests assert
calledOnce/ usefirstCall.args, which makes them brittle if additional requests are added later. Prefer asserting the expected request payload withcalledWith/calledWithMatchand avoid call-count / call-index assertions.
expect(sqlToolsClientStub.sendRequest.calledOnce).to.be.true;
const [type, params] = sqlToolsClientStub.sendRequest.firstCall.args;
expect(type).to.equal(SaveObjectRequest.type);
expect(params).to.deep.equal({
extensions/mssql/test/unit/dropDatabaseWebviewController.test.ts:129
- This test relies on exact call count/order (
calledOnce,firstCall.args), which is brittle if the controller starts making additional calls. Prefer asserting the expected params withcalledWithMatchrather than using call-count/index assertions.
expect(objectManagementServiceStub.dropDatabase.calledOnce).to.be.true;
const args = objectManagementServiceStub.dropDatabase.firstCall.args;
expect(args[1]).to.equal(databaseName);
expect(args[2]).to.be.true; // dropConnections
extensions/mssql/src/controllers/dropDatabaseWebviewController.ts:167
handleScriptdoesn't checkresponse.errorMessagebefore falling back to the generic "No script generated" warning whenscriptis missing. If the service returns a specific failure reason, return/surface that message so the dialog shows the real error.
const script = response.script;
if (!script) {
void this.vscodeWrapper.showWarningMessage(LocConstants.msgNoScriptGenerated);
return {
… database functionality Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 25 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (2)
extensions/mssql/src/controllers/dropDatabaseWebviewController.ts:169
handleScriptignoresresponse.errorMessagewhen no script is returned and always showsmsgNoScriptGenerated. Since the response type now includes an errorMessage, prefer surfacing that message (falling back tomsgNoScriptGenerated) so users get the real failure reason.
if (!script) {
void this.vscodeWrapper.showWarningMessage(LocConstants.msgNoScriptGenerated);
return {
success: false,
errorMessage: LocConstants.msgNoScriptGenerated,
extensions/mssql/test/unit/dropDatabaseWebviewController.test.ts:130
- This test uses
calledOnceplusfirstCall.args(call index) to validate behavior, which is brittle per the repo’s test guidelines. PrefercalledWith/calledWithMatchagainst the expected arguments, and avoid the setTimeout-basedwaitForInitialization(use a promise that resolves when initializeView completes, as done in the renameDatabase controller tests).
expect(objectManagementServiceStub.dropDatabase.calledOnce).to.be.true;
const args = objectManagementServiceStub.dropDatabase.firstCall.args;
expect(args[1]).to.equal(databaseName);
expect(args[2]).to.be.true; // dropConnections
expect(args[3]).to.be.false; // deleteBackupHistory
Description
Adds a new webview to rename database. This lets user generate scripts and close exiting connections.

Previously, if there was any existing connections, the rename object was just stuck until they were closed.
Depends on microsoft/sqltoolsservice#2652
Code Changes Checklist
npm run test)Reviewers: Please read our reviewer guidelines