sql-formatter
                                
                                 sql-formatter copied to clipboard
                                
                                    sql-formatter copied to clipboard
                            
                            
                            
                        Table name or alias "call" misinterpreted by formatter
Describe the bug When an alias for a table or expression is called "call", the formatter throws an error when trying to access its fields.
Expected behavior Running
sql = `SELECT call.id as "id" FROM c as call`;
console.log(format(sql, { language: "postgresql" }));
should work, but it doesn't. This, however, does:
sql = `SELECT calls.id as "id" FROM c as calls`;
console.log(format(sql, { language: "postgresql" }));
Actual behavior I got this error:
Error: Parse error at token: . at line 1 column 12
Unexpected PROPERTY_ACCESS_OPERATOR token: {"type":"PROPERTY_ACCESS_OPERATOR","raw":".","text":".","start":11}.
I assume this might happen for other keywords as well, not only "CALL".
Usage
- How are you calling / using the library? As described above
- What SQL language(s) does this apply to? PostgreSQL
- Which SQL Formatter version are you using? 13.1, but I also tested it on 15.3