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

db2i formatting does not work with JSON* functions #773

Open cmh716 opened 2 months ago

cmh716 commented 2 months ago

Describe the bug JSON_OBJECT, JSON_ARRAY, JSON_ARRAGG, etc do not work with this plugin

Expected behavior I expect these statements to be formatted

Actual behavior The plugin returns a parse error

Usage You can reproduce the issue on IBMi systems db2i:

SELECT JSON_OBJECT('key':'val') FROM SYSIBM.SYSDUMMY1;

To return complex JSON objects from DB2i, it's not uncommon to have a lot of JSON_OBJECTS and ARRAY, ARRAYAGG nested.

nene commented 2 months ago

Thanks for reporting.

I can confirm that the issue does reproduce, giving an error:

Parse error: Unexpected ":'val') FR" at line 1 column 25. SQL dialect used: "db2i".