Hey HN! We have released the initial version of the Postgres Language Server we started working on almost two years ago[0]. You can try it out by downloading the binary from the repo[1]. It is also available on npm, as a vscode extension and via nvim-lspconfig and mason.[2] We fell into plenty of rabbit holes along the way, but dug our way out of each. We're now using mostly pragmatic, almost naive solutions for our…
> we started working on almost two years ago Jesus, this really puts it into perspective how much effort JetBrains have put into their IDEs, which have had superb support for all popular SQL dialects for as long as I can remember. Thank you for providing the community with a FOSS alternative, because IIRC there wasn't anything remotely comparable to JetBrains up until now.
Postgres Language Server: Initial Release
21–30 of 58 posts
Re: Postgres Language Server: Initial Release
#22>This project provides a toolchain for Postgres development, I'm a little bit confused about what "Postgres development" is in this context. Is this for people writing stored procedures in Postgres? Or people writing other kinds of large and complex queries that merit language server support? I'm just kind of curious what uses cases are out there for something like this.
But some platforms (such as Supabase) rely on many parts of Postgres.
You use INSERT hooks to trigger queue insertions, Row Level Security (RLS) to secure data, SQL functions for aggregate queries. Plus the schema changes you do to support business use-cases.
Normally, you'll write these things into SQL migration files. Without an LSP, you'd have to look up the current state/implementation of schemas/functions, and you'd have to run the migrations to see whether there are errors. With the LSP, that's easier.
steinroe and I both use a lot of migrations in our day jobs (a whatsapp newsletter and a fintech startup).
Hope this helps.
Re: Postgres Language Server: Initial Release
#23What about parsing Py/C++/Rs/Java for SQL statements in strings? Perhaps by using multiline strings, VS Code could use a different language server depending on wether the line is within an SQL multiline string? That would allow statically checking and autocompleting SQL statements within strings in code. What are your thoughts on that?
In an ideal world there is static checkability of everything. Somehow, ideally, potential errors must be caught before runtime. For many type safe languages we can do this. With SQL we can do this now thanks to this language server. However, will it work when the SQL is embedded in code?
Re: Postgres Language Server: Initial Release
#24Hey HN! We have released the initial version of the Postgres Language Server we started working on almost two years ago[0]. You can try it out by downloading the binary from the repo[1]. It is also available on npm, as a vscode extension and via nvim-lspconfig and mason.[2] We fell into plenty of rabbit holes along the way, but dug our way out of each. We're now using mostly pragmatic, almost naive solutions for our…
My initial tests fails whenever there are CTEs. Are they not supported? I get
processing panicked: cannot start statement within statement at Some(Token { kind: With, text: "with", span: 0..4, token_type: ReservedKeyword })
whenever I try a file containing a CTE (this one was a file with this query: `with test as (select 1 as id) select * from test;`).Re: Postgres Language Server: Initial Release
#25Hey HN! We have released the initial version of the Postgres Language Server we started working on almost two years ago[0]. You can try it out by downloading the binary from the repo[1]. It is also available on npm, as a vscode extension and via nvim-lspconfig and mason.[2] We fell into plenty of rabbit holes along the way, but dug our way out of each. We're now using mostly pragmatic, almost naive solutions for our…
I am pretty excited about this. Thank you for all your effort. My initial tests fails whenever there are CTEs. Are they not supported? I get processing panicked: cannot start statement within statement at Some(Token { kind: With, text: "with", span: 0..4, token_type: ReservedKeyword }) whenever I try a file containing a CTE (this one was a file with this query: `with test as (select 1 as id) select * from test;`).
I'll file an issue with your exact query.
Re: Postgres Language Server: Initial Release
#26Assuming it works, this is a game changer. Currently I use DBeaver for SQL linting/autocomplete which is great. What about parsing Py/C++/Rs/Java for SQL statements in strings? Perhaps by using multiline strings, VS Code could use a different language server depending on wether the line is within an SQL multiline string? That would allow statically checking and autocompleting SQL statements within strings in code. Wh…
about embedded sql: you are right, this must be solved on the editor side. in vscode, it should be possible via request forwarding [0]. for neovim there are plugins like otter.nvim [1].
and at least for js, we are planning to add direct support for it in our workspace api so that `postgrestools check file.ts` will emit diagnostics for embedded sql. this is only feasible because we can easily parse js/ts code in rust via oxc[2] though. are you aware of similar tools in other languages?
[0] https://code.visualstudio.com/api/language-extensions/embedd... [1] https://github.com/jmbuhr/otter.nvim [2] https://oxc.rs
Re: Postgres Language Server: Initial Release
#27Hey HN! We have released the initial version of the Postgres Language Server we started working on almost two years ago[0]. You can try it out by downloading the binary from the repo[1]. It is also available on npm, as a vscode extension and via nvim-lspconfig and mason.[2] We fell into plenty of rabbit holes along the way, but dug our way out of each. We're now using mostly pragmatic, almost naive solutions for our…
I am pretty excited about this. Thank you for all your effort. My initial tests fails whenever there are CTEs. Are they not supported? I get processing panicked: cannot start statement within statement at Some(Token { kind: With, text: "with", span: 0..4, token_type: ReservedKeyword }) whenever I try a file containing a CTE (this one was a file with this query: `with test as (select 1 as id) select * from test;`).
[0] https://github.com/supabase-community/postgres-language-serv...
Re: Postgres Language Server: Initial Release
#28Earlier quoted context omitted.
I am pretty excited about this. Thank you for all your effort. My initial tests fails whenever there are CTEs. Are they not supported? I get processing panicked: cannot start statement within statement at Some(Token { kind: With, text: "with", span: 0..4, token_type: ReservedKeyword }) whenever I try a file containing a CTE (this one was a file with this query: `with test as (select 1 as id) select * from test;`).
Thanks for the report. Hmm, we have some tests for CTEs, so at least we tried to support them. I'll file an issue with your exact query.
Re: Postgres Language Server: Initial Release
#29Earlier quoted context omitted.
Thanks for the report. Hmm, we have some tests for CTEs, so at least we tried to support them. I'll file an issue with your exact query.
steinroe is a very fast man: https://github.com/supabase-community/postgres-language-serv...