Skip to content

Add support for running a command to get the database connection string in postgrestools.jsonc #302

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

Open
psteinroe opened this issue Apr 4, 2025 · 1 comment
Assignees

Comments

@psteinroe
Copy link
Collaborator

Discussed in #292

Originally posted by remorses April 1, 2025
I want to use the Supabase database directly instead of a local database, to do that you could add support for a config option dbCommand to get the database uri via stdout

{
  "$schema": "./docs/schemas/latest/schema.json",
  // get the database uri using dotenv-cli npm package
  "dbCommand": "dotenv -- bash -c 'echo $DATABASE_URL'",
  // get database uri using doppler
  "dbCommand": "doppler secrets get --plain DATABASE_URL",
}

This allows to get the database url using tools like Doppler or dotenv

@juleswritescode juleswritescode self-assigned this Apr 4, 2025
@willruggiano
Copy link
Contributor

willruggiano commented Apr 4, 2025

I would also love the ability to use InitializeParams and/or the workspace/didChangeConfiguration notification to configure this stuff, rather than be limited to a configuration file. The latter could enable switching database connections. Both options would then allow the client to determine the db parameters however they wanted, e.g. something along the lines of (in Neovim with lspconfig);

require("lspconfig").postgres_lsp.setup {
  settings = {
    postgres_lsp = {
      db = load_from_env()
    },
  }
}
-- You could map this in on_attach, for example. Or use Telescope. Or whatever.
function switch_database_connection(client --[[@type vim.lsp.Client]])
  client.notify(
    "workspace/didChangeConfiguration",
    {
      settings = { ... as above ... }
    }
  )
end

psteinroe pushed a commit that referenced this issue May 7, 2025
)

## What kind of change does this PR introduce?

It enables passing workspace settings via the
workspace/didChangeConfiguration notification. This in turn enables the
client to specify settings dynamically, rather than being limited to
configuration files. This is _a_ solution to #302. See example usage
(with lspconfig) here:
willruggiano/neovim.drv@9aa06ad.

## What is the current behavior?

There is none. The payload of this handler is currently ignored.

## What is the new behavior?

The configuration received by the handler is merged with the fs
configuration.

---------

Co-authored-by: Will Ruggiano <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants