microsoft / vscode-mssql

Visual Studio Code SQL Server extension.
Other
1.54k stars 459 forks source link

'definition' of some types of objects cannot be found #1126

Open msftrncs opened 6 years ago

msftrncs commented 6 years ago

I cannot get Peek or Go to Definition feature to work on user-defined types (including tables), scalar-valued functions or table value functions. The feature works fine for tables, views, and general stored procedures. The objects are clearly recognized, because help tips are provided if I hover over the items, but still 'no definition is found'.

Second, when the 'no definition is found' is displayed, it doesn't always show the correct full name of the object (most commonly on column names, which do not seem allow peeking the definition). If the object has spaces, only the clicked on word will be shown. If the object is preceded with 'dbo.' then I run in to the following:

Table Value Function: I get the definition of DBO User Defined Type: the 'type' definition is not found, or if clicked on the 'dbo' part, "definition not found for 'dbo'" User Defined Scalar Function: I get the definition of DBO

Server is a SQL 2008 Express instance. I have DBOwner role, and have no problem accessing these objects with MS SQL Management Studio (2017 edition). I also found that Intellisense failed with user defined types, though the other functions were in the suggestions.

I see the related issue #873, was affecting stored procedures, but I am not having trouble there.

jmferreirab commented 3 years ago

This seems to be related to the default database specified in the active connection of the editor tab you are working on.

Say you are trying to get the definition of procedure/view/table: MyTestDatabase.dbo.DailyResults

The proper definition will be retrieved if the active connection points to the database MyTestDatabase. As such, this can be temporarily "fixed" by running a "USE MyTestDatabase"

It would be great if the database did not have to match when a 3-part specification (database.schema.object) is provided. Instead, the 3-part specification name could used to determine the database in which the definition search should run against.