Open
Description
Describe the bug
Try to format a query that uses ODBC date and time literal syntax.
Microsoft - Date, Time, and Timestamp Escape Sequences
MariaDB - Date and Time Literals
Reproduce:
echo "SELECT {ts '2022-10-11 00:00:00'}" | ./node_modules/.bin/sql-formatter
Expected behavior
Correctly format or gracefully handle unexpected syntax instead of crashing
Actual behavior
Exception thrown in JS console:
Error: Parse error: Unexpected "{ts '2022-" at line 1 column 3318
at TokenizerEngine.createParseError (TokenizerEngine.js:53:12)
at TokenizerEngine.tokenize (TokenizerEngine.js:35:22)
at Tokenizer.tokenize (Tokenizer.js:16:47)
at LexerAdapter.tokenize (createParser.js:16:76)
at LexerAdapter.reset (LexerAdapter.js:17:24)
at Parser.feed (nearley.js:281:15)
at Object.parse (createParser.js:26:18)
at TransactSqlFormatter.parse (Formatter.js:60:49)
at TransactSqlFormatter.format (Formatter.js:53:22)
at format (sqlFormatter.js:69:36)
Usage
- How are you calling / using the library? Client side through angular pipe
- What SQL language(s) does this apply to? Any that use ODBC Date and Time literal syntax
- Which SQL Formatter version are you using? 11.0.2