microsoft / microsoft/vscode-mssql

[Bug]: "Move to Schema" shows a misleading "no movable object" error for same-schema/collision/memory-optimized cases

Open
#22,386 2 comments 0 reactions 1 assignee Claimed by @ssreerama View on GitHub
Area - SQL Project Bug User-filed
Dominant language
TypeScript
Stars
1.9k
Forks
610
Avg merge
2d 3h
Merged PRs (30d)
97

Description

### Description

When using "Move to Schema…" and selecting the schema the object is **already in**, the extension shows: "No object that can be moved to another schema was found at the cursor."

This message is misleading — there **is** a movable object at the cursor; it is simply already in the chosen schema. The same generic message is currently shown for several distinct situations, so the user can't tell what actually went wrong. It is shown when:

1. there is no object at the cursor,
2. the symbol is not a schema-level object,
3. the object is already in the selected schema (this report),
4. the object is a memory-optimized table (cannot be moved), and
5. an object with the same name already exists in the target schema (name collision).

Expected: clearer, situation-specific feedback. Two improvements (please do both):

1. **Better messages** — distinguish the cases instead of one generic message. For example:
- Already in schema: "'{object}' is already in the '{schema}' schema."
- Name collision: "An object named '{name}' already exists in the '{schema}' schema."
- Memory-optimized table: "Memory-optimized tables can't be moved to another schema."
2. **Exclude the current schema from the picker** — the QuickPick already knows the object's current schema (it shows it in the placeholder: "Current Schema: {0}, Select the new schema:"), so it should omit the current schema from the list. That prevents the same-schema selection (and its confusing message) entirely.

### Steps to Reproduce

1. Open a SQL project and open a file with a schema-qualified object (e.g. `CREATE TABLE [sales].[Product]`).
2. Place the cursor on the object, invoke Refactor → "Move to Schema…".
3. In the picker, choose the schema the object is already in (e.g. `sales`).
4. Observe the error: "No object that can be moved to another schema was found at the cursor." — even though there is a valid object at the cursor; it's just already in that schema.

### Affected Area

- SQL Database projects

### Environment Information

- VS Code Version: (please fill in)
- MSSQL Extension Version: (please fill in)
- Operating System: macOS
- Connection Type: N/A (SQL project / offline)

### Confirmation

- [x] I have searched existing issues and couldn't find a match
- [ ] I want to work on this issue

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.