kristijanhusak / vim-dadbod-ui

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

Query on save always canceled on Windows #125

Closed TheLeoP closed 2 years ago

TheLeoP commented 2 years ago

When I open a buffer, write a query and then save it, I get the following result:

unrecognized win32 error code: 123psql: error: C:/Users/pcx/AppData/Local/Temp/nvimeAR3CD/d2a141vflldbei-query-2022-03-31 22:47:30: Invalid argument

But, if I modify the buffer, doesn't save it and use the command :%DB the query works as expected. Also, if I first save the buffer, the query fails and then I sue the command :%DB, the query also fails with the same error.

I was trying to dig into the code, but I don't really know nearly enought vimscript. Maybe the autocmd that is run on save is altering the buffer content in some way (?). I try using the dos and unix fileformat, but the result was the same.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

TheLeoP commented 2 years ago

Today I finally try to solve this and I think I have found the solution. In Windows a filename can't contain colons (:) and this plugin creates it's temporary query files with a structure similar to something-2022-09-26 18:13:00. For some reason, Windows doesn't complain at Vim and let's it create the files normally, but when the argument is passed as a file name to the database executable (in my case psql.exe), it complains because of the colons in the filename. Could it be posible to replace the colons with another character? Should I open a PR doing it since it's a simple fix?

Edit: Ok, apparently the character used by this plugin isn't a color : but rather the unicode character 2236 called ratio , that's why Windows wasn't complaining. My guess now is that the psql executable on Windows doesn't like character unicodes because it complains about the path not existing even when using just vim-dadbod with the command :DB < path/to/file where path/to/file contains the ratio character.

kristijanhusak commented 2 years ago

Thanks for investigating. I updated it to use hyphens instead of space and colon, so this should hopefully fix the issue.