Fixing a null exception error when bound tables are null. (#1327)

* Fixing a null exception error when bound tables are null.

* skipping star expansion when there is no active conn

* Fixing a comment
This commit is contained in:
Aasim Khan
2021-12-02 14:15:26 -08:00
committed by GitHub
parent ec9294202e
commit 3b60f4b089
2 changed files with 29 additions and 14 deletions

View File

@@ -754,6 +754,15 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
starObjectIdentifier = (SqlObjectIdentifier)selectStarExpression.Children.ElementAt(0);
}
/*
Returning no suggestions when the bound tables are null.
This happens when there are no existing connections for the script.
*/
if (selectStarExpression.BoundTables == null)
{
return null;
}
List<ITabular> boundedTableList = selectStarExpression.BoundTables.ToList();
IList<string> columnNames = new List<string>();

View File

@@ -1659,12 +1659,18 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
this.currentCompletionParseInfo = scriptParseInfo;
resultCompletionItems = result.CompletionItems;
// Expanding star expressions in query
/*
Expanding star expressions in query only when the script is connected to a database
as the parser requires a connection to determine column names
*/
if (connInfo != null)
{
CompletionItem[] starExpansionSuggestion = AutoCompleteHelper.ExpandSqlStarExpression(scriptDocumentInfo);
if (starExpansionSuggestion != null)
{
return starExpansionSuggestion;
}
}
// if there are no completions then provide the default list
if (resultCompletionItems == null)