Live data from Hacker News

Postgres Language Server: Initial Release

github.com

51–58 of 58 posts

Re: Postgres Language Server: Initial Release

#51

Is there a way to make this work inside a browser, via monaco-editor? If so, do you have any examples, or recommendations?

I do not have experience with monaco, but you should be able to run the language server remotely and connect to it from the editor via the usual language server protocol.

we currently do not provide a wasm build which would enable us to run the server within the browser too, although that's something I am actively poking around with.

Re: Postgres Language Server: Initial Release

#52
post #2

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…

Any chance this will include formatting in the future?

Definitely. Of course, I can't promise that we can make it work properly, but it's high on our todo list.

Re: Postgres Language Server: Initial Release

#54

I'm very happy that something like this exists! I'm wondering why have there have been no good IDE experiences so far for Postgres? Or put another way, what has been the most challenging part of building this? Nothing I have tried so far comes close to what I'm used to with statically typed languages. One would think something as strict as Postgres would have good autocomplete by now but I've yet to find something.

Not sure what you’re looking for exactly.

If it’s just a nice GUI for interacting with postgres, Postico (for mac) is fantastic. Autocomplete is good, and the UI is very intuitive if you’re familiar with mac. It’s also a native app so it’s wicked fast. None of that web app pretending to be an app nonsense lol.

If you’re looking for a better experience interacting with a postgres server in a static typed language, like java, i’d check out Jooq. It’s been a while since i’ve used it but it basically lets you query a postgres database with proper types in your java code.

Re: Postgres Language Server: Initial Release

#55

The best I've seen is jetbrains. Not only does it parse the query but it matches against actual tables if you give it a source. The crazy part is it can do this for a SQL string in your code.

Not just in code, anywhere that accepts a comment (or carries a JSON Schema), e.g.

  # just as an example, I'm pretty sure that
  # IJ already knows this is SQL
  spring:
    datasource:
      hikari:
        # language=sql
        connection-test-query:
          SELECT count(1) FROM my_table
and also in not-obviously-sql literals

  #!/usr/bin/env python
  # language=sql
  MY_AWESOME_QUERY = """
  WITH awesome AS (
  -- ...
  ) SELECT * FROM awesome
  """

Re: Postgres Language Server: Initial Release

#56
post #15

Earlier quoted context omitted.

I suggest it would be helpful if the README's intro expanded a little more on the project's scope. "for postgres" is a bit vague, and "focusing on developer experience and reliable SQL tooling." doesn't tell me much about what it actually does. If I was coming to this project for the first time I think the questions I'd immediately like the answers to are: - What language is this language server for? Is it just for S…

Thanks for the feedback. Good points, we'll improve the README. Regarding your questions: 1. It's currently only for SQL statements, but we'll work on function bodies and PL/pgSQL soon. 2. Exactly, we follow the the PostgreSQL dialect (we use Postgres's parser) 3. You can give it a database connection and it will query some pg_catalog tables. If you don't provide connection details, we'll bypass features requiring th…

> You can give it a database connection and it will query some pg_catalog tables. If you don't provide connection details, we'll bypass features requiring that.

It'd be nice if users could manually obtain and provided that information.

Re: Postgres Language Server: Initial Release

#58
post #56

Earlier quoted context omitted.

Thanks for the feedback. Good points, we'll improve the README. Regarding your questions: 1. It's currently only for SQL statements, but we'll work on function bodies and PL/pgSQL soon. 2. Exactly, we follow the the PostgreSQL dialect (we use Postgres's parser) 3. You can give it a database connection and it will query some pg_catalog tables. If you don't provide connection details, we'll bypass features requiring th…

> You can give it a database connection and it will query some pg_catalog tables. If you don't provide connection details, we'll bypass features requiring that. It'd be nice if users could manually obtain and provided that information.

I agree. But you can just point it to an empty db with your schema.
Post reply on HN