sql-parser-cst icon indicating copy to clipboard operation
sql-parser-cst copied to clipboard

Postgres Support

Open shishkin opened this issue 2 years ago • 5 comments

I'm looking forward to this project to support Postgres dialect, so it can unblock Postgres support in the prettier plugin.

Edit: I'm hijacking this issue to track the overall progress of PostgreSQL support:

  • [ ] #42
    • Mostly done, some quirky edge-cases remaining, like allowing some reserved keywords as implicit aliases.
  • [ ] #49
    • Mostly done, some quirky edge-cases remaining, like full support for custom operators and the elaborate type casting syntax.
  • [ ] #96
    • Nothing yet.
  • [ ] #97
    • Nothing yet.
  • [x] #46
  • [x] #44
  • [x] #47
  • [x] #48
  • [x] #57
  • [x] #58
  • [x] #63
  • [x] #64
  • [x] #65
  • [x] #66
  • [ ] #67
    • CREATE/ALTER/DROP TRIGGER fully supported, EVENT TRIGGER support missing.
  • [x] #73
  • [ ] #78
    • Full support for domains, common cases for CREATE TYPE covered.
  • [ ] #94
    • Missing ALTER EXTENSION support.
  • [x] #99
  • [ ] #98
    • Nothing yet.
  • [x] #103
  • [ ] #105
    • Almost all (except comments on operators and aggregate functions)
  • [x] #113
  • [x] #114
  • [ ] #117
    • Missing ALTER SUBSCRIPTION support.
  • [ ] #118
    • CREATE/ALTER/DROP FOREIGN TABLE supported. Nothing else.
  • [ ] #43
    • I have barely started even mapping out the work that remains.

For reference: gram.y in Postgres Github repository.

shishkin avatar Apr 21 '23 11:04 shishkin

Would also love to see PostgreSQL support here 🙌 @nene is this something on the mid-term roadmap?

karlhorky avatar Oct 26 '23 16:10 karlhorky

Well, it is sort of on the roadmap since starting working on this whole library. But Postgres being pretty big and complex, just the thought of the task ahead puts me off from starting to implement support for it.

nene avatar Oct 26 '23 18:10 nene

Understood, thanks for the reply. Really appreciate the work that you're doing on both this project and sql-formatter.

I guess there's also not a way to build on existing parsers / existing schema data or use code generation somehow to reduce the implementation complexity here... 🤔

karlhorky avatar Oct 26 '23 18:10 karlhorky

To fully support postgres, it would be good to support psql meta commands (starting with \) and variables (with :), too.

wolfgangwalther avatar Feb 14 '24 11:02 wolfgangwalther

To fully support postgres, it would be good to support psql meta commands (starting with ) and variables (with :), too.

Yep. This is in the plans. But for now I'm concentrating on finishing the support for the actual SQL part.

Another thing to fully support Postgres is having support for PL/pgSQL.

I think both can be implemented as supersets of the base PostgreSQL grammar.

nene avatar Feb 17 '24 07:02 nene