emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.77k stars 882 forks source link

Cannot connect to databases when using sqls configuration settings in workspace #3200

Open FilipCon opened 2 years ago

FilipCon commented 2 years ago

Thank you for the bug report

Bug description

There seems to be an issue when connecting to the database with the sqls server when the setting lsp-sqls-workspace-config-path is set to "workspace" (default). Following the instructions on the webpage, I've tried setting the connections as the snippet states, i.e.:

(setq lsp-sqls-connections
    '(((driver . "mysql") (dataSourceName . "yyoncho:local@tcp(localhost:3306)/foo"))
      ((driver . "postgresql") (dataSourceName . "host=127.0.0.1 port=5432 user=yyoncho password=local dbname=sammy sslmode=disable"))))

The result is that I'm getting an error stating: Error processing message (wrong-type-argument json-value-p quote). I'm using Emacs 29.0.50 in Ubuntu.

Steps to reproduce

So, I tried setting the lsp-sqls-connections with the aforementioned method, both in my Emacs config and in my workspace as a .dir-locals file. I also tried creating a file <my-project-root-dir>/.sqls/config.json with contents similar to the following (as found in previous PR https://github.com/emacs-lsp/lsp-mode/pull/1832#issue-642545494).

{
  "sqls": {
    "connections": [
      {
        "driver": "mysql",
        "dataSourceName": "user1:password1@tcp(localhost:3306)/sample_db"
      }
    ]
  }
}

None of the above, or a combination of both, seemed to work.

What worked for me was to have (setq lsp-sqls-workspace-config-path nil) and a configuration file ~/.config/sqls/config.yml (note the non-required dot (.) in sqls dir and the .yml extension) with (all) my db connections set as:

connections:
  - alias: my-db-alias
    driver: postgresql
    proto: tcp
    user: user
    passwd: pass
    dbName: my-db-name
    host: 127.0.0.1
    port: 5432
    params:
      sslmode: disable
  - <next connection>

Expected behavior

I'd expect that after following the instructions I would get a list of connections after executing the code-action in the .sql buffer. However, setting the db connections locally (in workspace) does not seem to work at all.

Which Language Server did you use?

sqls

OS

Linux

Error callstack

No response

Anything else?

Am I missing something in my configuration? Thank you in advance and looking forward to your response.

TiFaBl commented 2 years ago

I just had the same experience, the <project>/.sqls/config.json was ignored, no matter if lsp-sqls-workspace-config-path was nil or workspace. The $HOME/.config/sqls/config.yml as well as the (setq lsp-sqls-connections ...) approach wokred fine.

quasi-coherent commented 3 months ago

The bug persists two years later.