vim-sql-workbench
vim-sql-workbench copied to clipboard
Can't connect to new profiles without restarting VIM
Reproduction:
- Open VIM
- Connect to an existing profile
- Open SQL Workbench and
- create new profile
- save changes
- Back in VIM issue "CtrlPClearSWCache"
- Open CtrlP with "CtrlPSW"
- Select new profile
Result buffer:
=SQL 1
A profile name or connection information is required.
Parameters for WbConnect are:
-profile The name of the connection profile to connect to
or
-username The DB user for the connection
-password The password for the DB user
-url The JDBC URL to connect to
-driver The driver class to use
-driverJar The classpath for the driver
-autocommit Control the autocommit setting
-rollbackOnDisconnect Issue a rollback before the connection is closed
-emptyStringIsNull Treat empty strings as null
-trimCharData Trim values from CHAR columns
Execution time: 0s
In .cache/sql-workbench/tmp/GVIM-__6__
:
MYPROFILE> wbconnect -profile="MYNEWPROFILE";wbschemareport types="TABLE,VIEW,MATERIALIZED VIEW,SYNONYM" -file=C:\Users\xxx/.cache/sql-workbench/tmp/GVIM-33 -objects=% -stylesheet=C:\Users\xxx\vimfiles\bundle\vim-sql-workbench\autoload/../resources/wbreport2vim.xslt -xsltOutput=C:\Users\xxx/.cache/sql-workbench/MYNEWPROFILE.vim;exitwbconnect -profile="MYNEWPROFILE";
A profile name or connection information is required.
Parameters for WbConnect are:
-profile The name of the connection profile to connect to
or
-username The DB user for the connection
...
After restarting VIM everything works as expected.
This is normal. When you connected the first time, an instance of sqlwbconsole.sh
was launched and associated with the current buffer.
After you tried to reconnect using the CtrlP
plugin, this will check if you already have a connection and not spawn another one. It will use the same and just do WbConnect
. So it's normal not to see the new profiles.
If you want to avoid restarting VIM, you need to also do (before CtrlP
) SWSqlBufferDisconnect
in the current sql buffer. This will terminate the current sqlwbconsole.sh
instance and then when you do CtrlP
again, it will spawn a new sqlwbconsole.sh
process which will see the new profiles.
Thank you for the hint. But may be you could also issue SWSqlBufferDisconnect
automatically, if a new connection is requested out of the already connected buffer...
This is not a good idea. When you do CtrlP
is normal and ok to re-use the existing instance. It is much more expensive to re-start the whole instance.
Is the same principle as with the GUI. You won't be re-starting the GUI
every time when you need to change the connection.
This being said, I can implement an option for whoever wishes to spawn a new instance of sqlwbconsole.sh
from CtrlP
which by default will be set to false.