microsoft / microsoft/vscode-mssql

[Bug]: Peek/Go to Definition doesn't work when schema and table share the same name

Open
#21,854 0 comments 0 reactions 1 assignee View on GitHub

@aasimkhan30 is already working on this.

Since May 11, 2026.

Area - Language Service Bug
Dominant language
TypeScript
Stars
1.9k
Forks
610
Avg merge
2d 3h
Merged PRs (30d)
97

Description

Description

Peek Definition / Go to Definition can resolve the wrong object when a schema and a table have the same name.

For example, if a schema named `Tasks` contains a table also named `Tasks` (`Tasks.Tasks`), definition lookup should resolve the schema name and table name separately based on cursor position. Instead, the wrong object can be returned.

Related Azure Data Studio issue:
https://github.com/microsoft/azuredatastudio/issues/2181

Steps to Reproduce

1. Connect to a SQL Server database.
2. Run the following setup script:

```sql
CREATE SCHEMA Tasks;
GO

CREATE TABLE Tasks.Tasks
(
TaskId int NOT NULL PRIMARY KEY,
TaskName nvarchar(100) NOT NULL,
CreatedAt datetime2 NOT NULL DEFAULT sysdatetime()
);
GO

INSERT INTO Tasks.Tasks (TaskId, TaskName)
VALUES
(1, N'alpha'),
(2, N'beta'),
(3, N'gamma');
GO
```

3. In a fresh query editor, run or paste:

```sql
SELECT *
FROM Tasks.Tasks;
```

4. Put the cursor on the first `Tasks` and invoke Peek Definition or Go to Definition.
5. Put the cursor on the second `Tasks` and invoke Peek Definition or Go to Definition again.

Expected Behavior

Definition lookup should be context-aware:
- the first `Tasks` should resolve to the schema definition
- the second `Tasks` should resolve to the table definition

Actual Behavior

Definition lookup resolves the wrong object when schema and table names are identical. In the ADS report, both lookups could incorrectly resolve to the schema definition.

Affected Area

- Query editor
- Other (please describe below)

If you selected "Other", please describe the affected area

Language service / definition resolution

Environment Information

- VS Code Version:
- MSSQL Extension Version:
- Operating System:
- SQL Server target/version:

Confirmation

- I have searched existing issues and couldn't find a match

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.