Skip to content

TransactSQL table WITH (NOLOCK) is formatted as WITH-clause. #867

Open
@LuciaCam

Description

@LuciaCam

Which SQL and options did you provide as input?
I am using the SQL Formatter VSCode extention with default settings except for the three following:
"SQL-Formatter-VSCode.dialect": "transactsql",
"SQL-Formatter-VSCode.functionCase": "upper",
"SQL-Formatter-VSCode.keywordCase": "upper",

The TransactSQL dialect does not seem to handle WITH (NOLOCK) appropriately. I think it considers it as a WITH statement, and it does not uppercase nolock automatically. For example:

Input data

select *
from table1 with (nolock)
left join table2 with (nolock) on table2.id = table1.id

Expected Output

SELECT
    *
FROM
    table1 WITH (NOLOCK)
    LEFT JOIN table2 WITH (NOLOCK) ON table2.id = table1.id

Actual Output

SELECT
    *
FROM
    table1
WITH
    (nolock)
    LEFT JOIN table2
WITH
    (nolock) ON table2.id = table1.id

Usage

  • How are you calling / using the library?
    I am using the SQL Formatter VSCode extention.
  • What SQL language(s) does this apply to?
    TransactSQL
  • Which SQL Formatter version are you using?
    The extension is v4.2.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions