darold / pgFormatter

A PostgreSQL SQL syntax beautifier that can work as a console program or as a CGI. On-line demo site at http://sqlformat.darold.net/
PostgreSQL License
1.64k stars 101 forks source link

unicode characters doesn't handled well in function #246

Closed holymonson closed 3 years ago

holymonson commented 3 years ago

Names with unicode character doesn't handled well in function variable.

-- doesn't work well
SELECT
    date_trunc('month', 日期) FROM table_;

-- works well 
SELECT
    date_trunc('month', date_)
FROM
    table_;
darold commented 3 years ago

pgFormatter function tokenize_sql() is not tokenizing this query correctly, it detects 日期) instead of two separate token. I guess it is worst with more complex queries. If you enclose the object name between double quote the tokenizer should work but at this time I have no evident solution for this problem that can be fixed in pgFormatter.

darold commented 3 years ago

Commit ab94060 should fix this issue.