Skip to content

SQL Formatter breaks scripts by moving comments to end of lines and merging table elements #215

@ssreerama

Description

@ssreerama

Description:

When using format sql, comments between table elements are incorrectly moved to the end of the previous line, causing SQL elements to merge and creating invalid syntax.

Impact:

Critical - Breaks SQL syntax in Visual Studio/SSMS "Format Document" command
Results in unparseable SQL that fails to execute
Affects table creation scripts with inline comments
Steps to Reproduce

Repor:
CREATE TABLE dbo.VETask
(
Id INT,
TaskNo INT,
Status INT
--IsActive BIT NOT NULL CONSTRAINT DF_VETask_IsActive DEFAULT 1
CONSTRAINT PK_VETask PRIMARY KEY CLUSTERED (Id),
--CONSTRAINT UQ_VETask_TaskNo UNIQUE (TaskNo)
INDEX IX_VETask_Status NONCLUSTERED (Status),
);

actual result:
CREATE TABLE dbo.VETask (
Id INT,
TaskNo INT,
Status INT CONSTRAINT PK_VETask PRIMARY KEY CLUSTERED (Id), --IsActive BIT NOT NULL CONSTRAINT DF_VETask_IsActive DEFAULT 1
--CONSTRAINT UQ_VETask_TaskNo UNIQUE (TaskNo)
INDEX IX_VETask_Status NONCLUSTERED (Status));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions