sql-formatter-org / sql-formatter

A whitespace formatter for different query languages
https://sql-formatter-org.github.io/sql-formatter/
MIT License
2.37k stars 405 forks source link

[FORMATTING] var := value Token for Snowflake is Parsed as var: = value. #775

Closed chiefupstart closed 2 months ago

chiefupstart commented 2 months ago

Input SQL

DECLARE
 profit NUMBER(38, 2);
 revenue NUMBER(38, 2);
 cost NUMBER(38, 2);
BEGIN
 let profit := revenue - cost;
RETURN profit;

Expected Output I would expect sql-formatter to honor the := symbol for Snowflake.

Actual Output

Parse error at token: = at line 6 column 13 <-- notice the space in the token.
Unexpected OPERATOR token: {"type":"OPERATOR","raw":"=","text":"=","start":91}. Instead, I was expecting to see one of the following:
A LINE_COMMENT token based on: ...
A BLOCK_COMMENT token based on: ...
A DISABLE_COMMENT token based on: ...
Etc etc.

Usage

      let serverLanguage: SqlLanguage = 'snowflake';
      formattedSql = format(sqlText, {
        language: serverLanguage,
        tabWidth: 2,
        keywordCase: 'upper',
        linesBetweenQueries: 1,
      });

Version: "sql-formatter": "^15.4.1"

nene commented 2 months ago

Thanks for reporting.

nene commented 2 months ago

Fixed in 15.4.2