microsoft / azuredatastudio

Azure Data Studio is a data management and development tool with connectivity to popular cloud and on-premises databases. Azure Data Studio supports Windows, macOS, and Linux, with immediate capability to connect to Azure SQL and SQL Server. Browse the extension library for more database support options including MySQL, PostgreSQL, and MongoDB.
https://learn.microsoft.com/sql/azure-data-studio
MIT License
7.57k stars 901 forks source link

Keyword coloring is broken from unbalanced ' characters in some contexts #4630

Open geleems opened 5 years ago

geleems commented 5 years ago

Keyword coloring on script seems to be broken in query window

image

BEGIN TRY
    BEGIN TRANSACTION T4bb25d3d835645a38749054e3a316de
        USE [Verify_Hierarchy_Baseline_Sqlv150'']]]]]]'{a15a7e31-47ab-48f4-a380-42279406d3ed}];
        CREATE DATABASE SCOPED CREDENTIAL [sa]
            WITH IDENTITY = N'sa', SECRET = N'Yukon900';
        CREATE EXTERNAL DATA SOURCE [MyDs]
            WITH (LOCATION = N'sqlserver://sqltools2017-3', CREDENTIAL = [sa]);
        EXEC(N'CREATE SCHEMA []]]]]]]]dbo[[[]');
        CREATE EXTERNAL TABLE []]]]]]]]dbo[[[].[test[table]]]
        (
            [c[o]]l1] INT
        )
        WITH (LOCATION = N'[keep_genetest]]].[dbo].[test[table]]]', DATA_SOURCE = [MyDs]);
        EXEC(N'CREATE SCHEMA [[[]]]]]]]]]]dbo[[[]');
        CREATE EXTERNAL TABLE [[[]]]]]]]]]]dbo[[[].[Table1]
        (
            [Id] INT NOT NULL,
            [a] NVARCHAR(50) COLLATE Latin1_General_CS_AS
        )
        WITH (LOCATION = N'[keep_chlafren].[dbo].[Table1]', DATA_SOURCE = [MyDs]);
    COMMIT TRANSACTION T4bb25d3d835645a38749054e3a316de
END TRY
BEGIN CATCH
    IF @@TRANCOUNT > 0
        ROLLBACK TRANSACTION T4bb25d3d835645a38749054e3a316de
    DECLARE @ErrorMessage NVARCHAR(4000) = ERROR_MESSAGE();
    DECLARE @ErrorSeverity INT = ERROR_SEVERITY();
    DECLARE @ErrorState INT = ERROR_STATE();
    RAISERROR(@ErrorMessage, @ErrorSeverity, @ErrorState);
END CATCH;
adsbot[bot] commented 5 years ago

Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

kburtram commented 5 years ago

@geleems to clarify the script, Verify_Hierarchy_Baseline_Sqlv150'']]]]]]'{a15a7e31-47ab-48f4-a380-42279406d3ed} is the name of the database?

It looks like the plist grammar is getting hung up with the unbalanced ' characters.

geleems commented 5 years ago

Yes, it is the database name. The script is valid, and runs successfully.

kburtram commented 5 years ago

thanks @geleems. I've updated the issue title to more precisely reflect the problem.

geleems commented 5 years ago

@kburtram Thanks, Karl!