Skip to content

SQL with $ inside the column name are not parsed and formatted. #830

@traycho

Description

@traycho

Input data

Which SQL and options did you provide as input?

SELECT A.T$REFA orderId from TABLE_NAME;

Expected Output

SELECT  
   A.T$REFA orderId 
from 
TABLE_NAME;

Actual Output

Error: Parse error: Unexpected "$REFA orde" at line 1 column 11.
This likely happens because you're using the default "sql" dialect.
If possible, please select a more specific dialect (like sqlite, postgresql, etc).
    at TokenizerEngine.createParseError (TokenizerEngine.ts:61:12)
    at TokenizerEngine.tokenize (TokenizerEngine.ts:49:22)
    at Tokenizer.tokenize (Tokenizer.ts:26:65)
    at LexerAdapter.tokenize (createParser.ts:23:37)
    at LexerAdapter.reset (LexerAdapter.ts:18:24)
    at Parser.feed (nearley.js:281:15)
    at Object.parse (createParser.ts:33:34)
    at Formatter.parse (Formatter.ts:37:49)
    at Formatter.format (Formatter.ts:31:22)
    at formatDialect (sqlFormatter.ts:97:57)

Usage

  • How are you calling / using the library?
import { format as formatSQL } from "sql-formatter";
const sql = 'SELECT A.T$REFA orderId from TABLE_NAME;'
format(sql, { language: "sql" })

  • What SQL language(s) does this apply to?
    All of them I guess.

  • Which SQL Formatter version are you using?
    15.4.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions