Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psql multi-line on Sublime breaks #24

Open
njoshi023 opened this issue May 21, 2014 · 7 comments
Open

psql multi-line on Sublime breaks #24

njoshi023 opened this issue May 21, 2014 · 7 comments

Comments

@njoshi023
Copy link

Hi,

Thanks for making this awesome plugin. While it works very well when I inline my entire psql query, I do get an error if I split even the simplest query such as the one down below into multiple lines

select count(*)
from mytable
ERROR:  syntax error at or near "from"
LINE 1: from mytable
-- This will work though
select count(*) from mytable

This naturally limits the ability to perform complex queries. Let me know if you are aware of this issue and if I can help fix it. Thanks

@njoshi023
Copy link
Author

Quick update - this does work if I select the entire query contents. Otherwise it only executes the query on the line the cursor is on. So feel free to close the issue if you think that is sufficient. But it seems like upon SQL execute, we should select all the contents of the file and not just the line the cursor is on. Thanks

@babyman
Copy link

babyman commented May 21, 2014

I just ran into this issue, thanks for updating the ticket @njj023 I was about to give up and move on. Selecting the file or even better selecting the statement that the cursor is placed within would be ideal.

@jum4
Copy link
Owner

jum4 commented May 21, 2014

Hi,
you're right, today the execute command executes only the current line, maybe we should add another command running all file, or searching for an ";" to execute the current query.
I'm thinking about it

@Cottin
Copy link

Cottin commented Jul 3, 2014

+1 for the searching for an ";" solution!

Same problem with MySql:

select * from customer where id = 592;  -- Works!

select * from customer
where id = 592;  -- Only works if you select the two lines!

To execute the statement before the ";" is a very common work practice in MySQL Workbench, so I think this would be an appreciated feature for people use to that :)

@xolvo
Copy link

xolvo commented Jul 9, 2014

Suggest to execute entire file and let db output results. For example if there 2 queries in file separated with ; it will print 2 tables in result's window.

@Cottin
Copy link

Cottin commented Jul 9, 2014

I don't agree with @xolvo 's idea.. For me it would be nicer if it worked like MySQL Workbench where it only executes one statement. Often my (and my colleges) files contains 8 statements (or more) separated by ;, if all were executed there would be too many tables in the result's window.

@woodybrood
Copy link

Personally I would really appreciate the option to select and execute the whole file. I recognize @Cottin has a point that sometimes a user doesn't want to run the whole file. In my case, sometimes I want to run files that have variables set at the start and cleared later. to do that you really do want the whole file to be executed to ensure things work right.

So maybe two executes, execute all and execute current statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants