Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: expose parsing apis #753

Closed
DanielFGray opened this issue Jun 30, 2024 · 3 comments
Closed

Feature Request: expose parsing apis #753

DanielFGray opened this issue Jun 30, 2024 · 3 comments
Labels

Comments

@DanielFGray
Copy link

it would be amazing if the parsing apis were exported, so other projects can take advantage of them
personally i would love to see the parser being broken into a separate package, but i can understand the maintenance overhead that might require

willing to head up a PR if this is acceptable

@nene
Copy link
Collaborator

nene commented Jun 30, 2024

Well, do you personally have a project that would like to take advantage of it, or is it more of an abstract request?

The things is, the parser isn't really much of a parser (as in, producing a proper AST), it's very specifically tailored for the needs of the formatter.

If you're looking for an SQL parser, you might instead want to consider sql-parser-cst, which I specifically created to overcome the massive limitations that the "parser" in sql-formatter has. It's used by prettier-plugin-sql-cst to format SQL in much better way than will ever be possible with the architecture of SQL Formatter.

@DanielFGray
Copy link
Author

do you personally have a project that would like to take advantage of it

I do. I tried sql-parser-cst but it doesn't seem to work for anything more than very simple sql commands (see here for an example of something more advanced)

I can open parsing issues in that repo if you're interested

@nene
Copy link
Collaborator

nene commented Jun 30, 2024

Well, it does support all the syntax of SQLite and BigQuery, but that's indeed very simple SQL compared to all of PostgreSQL, which will need a substantial amount of additional work before it's fully finished. It is though the most complete PostgreSQL parser implementation in JavaScript that I'm aware of. I did quite a lot of experimenting with existing ones before I finally decided to write my own.

There's an issue that tracks the progress of Postgres implementation.

If a part that's marked as supported in there is not working, then it's indeed worth of opening a ticket. But no real point of opening tickets about the parts of syntax for which nothing has been implemented yet. Then again I haven't even mapped out all the work that remains, like the GRANT/REVOKE syntax that's used at the beginning of that big SQL file you referenced. So it might be worthwhile to open a ticket about that, or just adding a vote for existing tickets for unimplemented stuff. That way I can possibly prioritize implementing the parts that people care the most about.

@DanielFGray DanielFGray closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants