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

added support for decimal values without leading digits #794

Closed jagmitswami closed 3 weeks ago

jagmitswami commented 4 weeks ago

Encountered issue while handling decimal values without leading digits (for example .00457). Lexer was breaking, updated number token regex to support the similar cases and added a corresponding test case.

Sample SQL query: SELECT employee_id FROM employees WHERE salary > .456 * 1000000 AND bonus < .0000239 * salary;

An Unexpected Error Occurred
Parse error at token: 456 at line 1 column 51 Unexpected NUMBER token: {"type":"NUMBER","raw":"456","text":"456","start":50}
codesandbox-ci[bot] commented 4 weeks ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

nene commented 3 weeks ago

Thanks a lot!