Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format-on-save for UNION statements continues to indent first line #802

Closed
1 of 5 tasks
cnpryer opened this issue Apr 28, 2021 · 1 comment
Closed
1 of 5 tasks

Format-on-save for UNION statements continues to indent first line #802

cnpryer opened this issue Apr 28, 2021 · 1 comment
Labels

Comments

@cnpryer
Copy link

cnpryer commented Apr 28, 2021

Describe the bug
Every time I save my SELECT in my UNION statements will indent. So if I continue to save over and over it'll continue to indent.

Image from Gyazo

Example Snippet
SELECT
    DISTINCT
    t
FROM
    (SELECT *, 0 AS s FROM [db]..t UNION SELECT *, 1 AS s FROM [db]..t) AS r

Logs

I believe these logs are unrelated, but just in case
Error - 1:32:07 PM] Request textDocument/definition failed.
  Message: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at Babel.ParserGenerator.MinimalList`1.get_Item(Int32 index)
   at Babel.ParserGenerator.ModifiedMinimalList`1.get_Item(Int32 index)
   at Microsoft.SqlServer.Management.SqlParser.Parser.TokenManager.GetToken(Int32 tokenNumber)
   at Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion.ScriptDocumentInfo.GetPeekDefinitionTokens(ScriptParseInfo scriptParseInfo, Int32 startLine, Int32 startColumn) in D:\a\1\s\src\Microsoft.SqlTools.ServiceLayer\LanguageServices\ScriptDocumentInfo.cs:line 158
   at Microsoft.SqlTools.ServiceLayer.LanguageServices.LanguageService.GetDefinition(TextDocumentPosition textDocumentPosition, ScriptFile scriptFile, ConnectionInfo connInfo) in D:\a\1\s\src\Microsoft.SqlTools.ServiceLayer\LanguageServices\LanguageService.cs:line 1379
   at Microsoft.SqlTools.ServiceLayer.LanguageServices.LanguageService.HandleDefinitionRequest(TextDocumentPosition textDocumentPosition, RequestContext`1 requestContext) in D:\a\1\s\src\Microsoft.SqlTools.ServiceLayer\LanguageServices\LanguageService.cs:line 519
  Code: 0 

To Reproduce
Steps to reproduce the behavior:

  1. Create a .sql file
  2. Paste Example Snippet above
  3. Update settings to uppercase everything
  4. Save

Expected behavior
A result of something like:

SELECT
    DISTINCT
    t
FROM (
    SELECT 
        *, 0 AS s 
    FROM [db]..t 
    UNION 
    SELECT 
        *, 
        1 AS s 
    FROM [db]..t
) AS r

Desktop (please complete the following information):

  • SQLTools Version [1.10.1]
  • VSCode Version: [1.55.2]
  • OS: [Windows]
  • Driver:
    • PostgreSQL/Redshift
    • MySQL/MariaDB
    • MSSQL/Azure - though I'm not sure how this is utilized for this bug
    • SQLite
    • Other? Which...
  • Database version: [MSSQL 13.0.5698.0?]

Additional Context
I've tested this with working code in addition to this pseudo-code.

@cnpryer cnpryer added the triage label Apr 28, 2021
@cnpryer
Copy link
Author

cnpryer commented Jun 29, 2022

User error.

@cnpryer cnpryer closed this as completed Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant