launchql / pgsql-parser

PostgreSQL Query Parser for Node.js
MIT License
162 stars 24 forks source link

Improve debugability in kitchen sink test failures #81

Closed acarl005 closed 2 years ago

acarl005 commented 2 years ago

This is my followup to #80. This PR makes the following cases easier to debug:

1. A syntax error trying to parse a SQL fixture file.

Before

Vague message like "syntax error at or near FROM"

Screen Shot 2022-07-14 at 14 39 22

After

Show exact line and column

Screen Shot 2022-07-14 at 14 36 49

2. Test failures b/c deparsing produces non-equivalent SQL

Before

Giant diff with potentially thousands/tens-of-thousands of lines of JSON AST

Screen Shot 2022-07-14 at 14 45 49

After

Diff for a single statement, as well as the before-deparsing and after-deparsing of the SQL statements

Screen Shot 2022-07-14 at 15 26 40

Note that the snapshots changed a lot since I'm checking statements 1-at-a-time now. However, this PR doesn't actually include any changes to the content of the tests or library functionality.

pyramation commented 2 years ago

this looks amazing! I checked it out and all seems great and tests passing.

pyramation commented 2 years ago

thanks for this @acarl005 — this will be super helpful. I think I may want to try adding this into https://github.com/pyramation/postgres-ast-deparser which has the same test env