sqls.nvim icon indicating copy to clipboard operation
sqls.nvim copied to clipboard

Cannot switch database with SqlsSwitchDatabase

Open idr4n opened this issue 2 years ago • 3 comments

Hi,

Thanks for this plugin. Everything is working for me, however I cannot switch databases with :SqlsSwitchDatabase. After selection the number of the desired database, nothing happens, I don't get any errors or anything but it remains in the same database.

The way I can manage to actually switch databases is by defining another connection in the configuration with another database, and then switching connections instead.

This is my config:

require("lspconfig").sqls.setup({
	on_attach = function(client, bufnr)
		require("setup.lsp.handlers").on_attach(client, bufnr)
		require("sqls").on_attach(client, bufnr)
	end,
	capabilities = require("setup.lsp.handlers").capabilities,
	settings = {
		sqls = {
			connections = {
				{
					driver = "postgresql",
					dataSourceName = "host=127.0.0.1 port=5432 user=iduran dbname=test",
				},
				{
					driver = "postgresql",
					dataSourceName = "host=127.0.0.1 port=5432 user=iduran",
				},
			},
		},
	},
})

idr4n avatar Jul 18 '22 09:07 idr4n

I can reproduce by manually sending a request to the server:

vim.lsp.buf_request(0, 'workspace/executeCommand', {command = 'switchDatabase', arguments = {'testdb'}}, function() end)

It works with the mysql driver though, so I'm almost sure the problem is either in sqls or in the postgresql driver

nanotee avatar Jul 18 '22 12:07 nanotee

Thanks for letting me know. Feel free to close this issue if you think is not being caused by your plugin then.

idr4n avatar Jul 18 '22 13:07 idr4n

      connections = {
        {
          driver = 'postgresql',
          dataSourceName = 'postgres://<user>:<password>@localhost/<database_name>?sslmode=disable',
        },
      },

RAprogramm avatar Jan 27 '23 04:01 RAprogramm