Warn on duplicate object name for Rename and Move to Schema#22409
Open
ssreerama wants to merge 5 commits into
Open
Warn on duplicate object name for Rename and Move to Schema#22409ssreerama wants to merge 5 commits into
ssreerama wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the SQL rename and move-to-schema workflows to surface server-provided name-collision warnings to the user and require explicit confirmation before applying edits, aligning behavior with SSDT-style prompts instead of failing silently.
Changes:
- Extended the language service response contracts to optionally carry a
warningMessage. - Added a Yes/No confirmation prompt in both Rename and Move-to-Schema providers when
warningMessageis present. - Removed root and extension
.vscode/launch.jsondebug configurations (not mentioned in the PR description).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/mssql/src/models/contracts/languageService.ts | Adds optional warningMessage fields to rename/move response contracts. |
| extensions/mssql/src/languageservice/sqlSymbolRenameProvider.ts | Prompts user (Yes/No) when the service warns about a name collision before returning edits. |
| extensions/mssql/src/languageservice/sqlMoveToSchemaProvider.ts | Prompts user (Yes/No) when the service warns about a name collision before applying edits. |
| extensions/mssql/.vscode/launch.json | Deleted extension-level debug launch configuration. |
| .vscode/launch.json | Deleted root-level debug launch configuration used for “Run All Extensions”. |
17 tasks
PR Changes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22409 +/- ##
===========================================
- Coverage 87.74% 75.57% -12.18%
===========================================
Files 325 413 +88
Lines 113984 129655 +15671
Branches 560 8270 +7710
===========================================
- Hits 100020 97992 -2028
- Misses 13964 31663 +17699
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
78d452c to
f1812be
Compare
5b376f1 to
65e58b6
Compare
…sage with single message + isWarning flag
Comment on lines
+178
to
+184
| /** | ||
| * When non-null, a message to surface to the user. | ||
| * If isWarning is true, show a confirmation dialog; otherwise show a blocking error. | ||
| */ | ||
| message?: string | null; | ||
| /** True when message is a confirmation warning; false (default) when it is a hard rejection. */ | ||
| isWarning?: boolean; |
Comment on lines
+214
to
+220
| /** | ||
| * When non-null, a message to surface to the user. | ||
| * If isWarning is true, show a confirmation dialog; otherwise show a blocking error. | ||
| */ | ||
| message?: string | null; | ||
| /** True when message is a confirmation warning; false (default) when it is a hard rejection. */ | ||
| isWarning?: boolean; |
Comment on lines
+155
to
+170
| // Hard rejection — surface the error message and abort. | ||
| if (response.message && !response.isWarning) { | ||
| throw new Error(response.message); | ||
| } | ||
|
|
||
| // Name collision warning — ask the user before proceeding. | ||
| if (response.message && response.isWarning) { | ||
| const choice = await vscode.window.showWarningMessage( | ||
| response.message, | ||
| { modal: true }, | ||
| msgYes, | ||
| ); | ||
| if (choice !== msgYes) { | ||
| return new vscode.WorkspaceEdit(); // user declined — apply nothing silently | ||
| } | ||
| } |
Comment on lines
+190
to
+200
| // Warn if an object with the same name already exists in the target schema. | ||
| if (response.message && response.isWarning) { | ||
| const choice = await vscode.window.showWarningMessage( | ||
| response.message, | ||
| { modal: true }, | ||
| msgYes, | ||
| ); | ||
| if (choice !== msgYes) { | ||
| return; // user declined — do nothing silently | ||
| } | ||
| } |
Comment on lines
+370
to
+372
| message: | ||
| "A schema object with the name [Orders] already exists. Would you like to continue?", | ||
| isWarning: true, |
Comment on lines
+405
to
+407
| message: | ||
| "A schema object with the name [Orders] already exists. Would you like to continue?", | ||
| isWarning: true, |
Comment on lines
+830
to
+832
| message: | ||
| "A schema object with the name [hr].[MyTable] already exists. Would you like to continue?", | ||
| isWarning: true, |
Comment on lines
+859
to
+861
| message: | ||
| "A schema object with the name [hr].[MyTable] already exists. Would you like to continue?", | ||
| isWarning: true, |
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
When renaming a SQL object or moving it to a schema where a name conflict exists, the client now shows a Yes/Cancel confirmation dialog (matching the SSDT-style prompt) before applying the workspace edits. Previously the operation was silently rejected with no feedback.
Changes
Contracts (
languageService.ts)SqlSymbolRenameResponse— addedwarningMessage?propertySqlMoveToSchemaResponse— addedwarningMessage?propertyRename provider (
sqlSymbolRenameProvider.ts)response.warningMessageis set, shows ashowWarningMessageprompt with Yes / Cancel buttons before proceeding.Move to Schema provider (
sqlMoveToSchemaProvider.ts)Depends on microsoft/sqltoolsservice#2748