Skip to content

For some dialects, SQL statements containing the ? placeholder cannot be processed normally. #806

@meiMingle

Description

@meiMingle

Input data

sqlFormatter.format('SELECT * FROM tbl WHERE foo = ?', {
  language:'plsql',
  params: ["'bar'"]
})

Expected Output

select
  *
from
  table
where
  name like 'bar'

Actual Output

image

TokenizerEngine.ts:49 Uncaught Error: Parse error: Unexpected "?" at line 1 column 31.
SQL dialect used: "plsql".
at HR.createParseError (TokenizerEngine.ts:61:12)
at HR.tokenize (TokenizerEngine.ts:49:22)
at VR.tokenize (Tokenizer.ts:26:65)
at wR.tokenize (createParser.ts:23:37)
at wR.reset (LexerAdapter.ts:18:24)
at Object.parse (createParser.ts:33:34)
at tA.parse (Formatter.ts:37:49)
at tA.format (Formatter.ts:31:22)
at oA (sqlFormatter.ts:97:57)

Usage

  • How are you calling / using the library?

  • What SQL language(s) does this apply to?
    redshift,hive,plsql,singlestoredb,snowflake,spark,transactsql
    These dialects have this problem.

  • Which SQL Formatter version are you using?
    v15.4.6

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