launchql / pgsql-parser

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

Unwrap Lists in deparse instead of preparsing the AST + remove lodash #98

Closed benasher44 closed 1 year ago

benasher44 commented 1 year ago

This cuts total runtime of our internal test suite by 38%.

Summary of changes:

With the above, we can remove preparse.js

Closes #97

benasher44 commented 1 year ago

@pyramation one thing to consider is downstream libpg_query has deparse now, starting with postgres 13. do you think it's possible to use it? If so, that could reduce library maintenance here to automatic maintenance of symmetric versions + maintaining the build

pyramation commented 1 year ago

Thanks @benasher44 ! this is great

@pyramation one thing to consider is downstream libpg_query has deparse now, starting with postgres 13. do you think it's possible to use it? If so, that could reduce library maintenance here to automatic maintenance of symmetric versions + maintaining the build

So, I'm open to it! But I'd prefer making another package, perhaps, native-deparse, because currently the deparse package doesn't rely on any C code or the postgres build. The current deparse is pure javascript which makes it super portable.

pyramation commented 1 year ago

Btw, I'm merging into a develop branch so I can run tests, for some reason the testing CI didn't run with this PR.

pyramation commented 1 year ago

https://github.com/pyramation/pgsql-parser/actions/runs/4421396540/jobs/7752144298

benasher44 commented 1 year ago

Awesome thanks!

benasher44 commented 1 year ago

Thanks @benasher44 ! this is great

@pyramation one thing to consider is downstream libpg_query has deparse now, starting with postgres 13. do you think it's possible to use it? If so, that could reduce library maintenance here to automatic maintenance of symmetric versions + maintaining the build

So, I'm open to it! But I'd prefer making another package, perhaps, native-deparse, because currently the deparse package doesn't rely on any C code or the postgres build. The current deparse is pure javascript which makes it super portable.

That's fair. We may look into it, and if we open a PR, we'll make it a separate package then. Are people making SQL ASTs without going through the parser (which relies on C code)?