kristijanhusak / vim-dadbod-ui

Simple UI for https://github.com/tpope/vim-dadbod
MIT License
1.54k stars 94 forks source link

Wrong {dbname} variable in MySQL #108

Closed dsolay closed 3 years ago

dsolay commented 3 years ago

I had this connection url in my .env file

DB_UI_CONNECTION_NAME=mysql://user:pass@localhost:3306/db-name

and this table helper

USE INFORMATION_SCHEMA;
SELECT TABLE_NAME,
       COLUMN_NAME,
       CONSTRAINT_NAME,
       REFERENCED_TABLE_NAME,
       REFERENCED_COLUMN_NAME
FROM KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = "{dbname}"
  AND TABLE_NAME = "{table}"

then this is the result helper

USE INFORMATION_SCHEMA;
SELECT TABLE_NAME,
       COLUMN_NAME,
       CONSTRAINT_NAME,
       REFERENCED_TABLE_NAME,
       REFERENCED_COLUMN_NAME
FROM KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = "CONNECTION_NAME"
  AND TABLE_NAME = "table_name"

note that {dbname} is replaced with "CONNECTION_NAME" instead of "db-name"

Tested on:

kristijanhusak commented 3 years ago

I pushed a fix. Let me know if it works ok now.