elementary-community / sequeler

SQL Client built in Vala
GNU General Public License v3.0
804 stars 66 forks source link

Execute Multiple Queries. #56

Open ar0ra1 opened 6 years ago

ar0ra1 commented 6 years ago

Right Now, it only executes the first query and ignores the remaining ones.

emanchado commented 6 years ago

I was about to file the same issue :-) I guess the general solution would imply using an SQL parser (there seem to be several written in C and C++ on GitHub), but for a first solution it might be enough with a simple lexer that only understands comments and strings, and then simply splits by semicolon.

I might be able to help a bit but I haven't programmed C (or used lex) in ages and I have never programmed in Vala :-)

Edit: On second thought, what I expect is actually that only the query under the cursor will be executed (ie. what happens in DataGrip, which is great BTW). I guess if there's an active selection all the selected SQL should be sent as a query... that would cover @ar0ra1's usecase.

Alecaddd commented 6 years ago

Thanks both for the report and suggestion. The Gda Library for database queries is not the most intuitive in handling a query string, and as you noticed, it's really basic. Added to the backlog of future updates and features.

Alecaddd commented 6 years ago

Pushing a new version with the fix for this issue later tomorrow!

ar0ra1 commented 6 years ago

It still doesn't run the second query!

Alecaddd commented 6 years ago

That's a limitation of the LibGDA that unfortunately I can't fix. I'm working on the new version where I'm gonna drop that library and use specific database bindings. That'll solve it.

diethardsteiner commented 6 years ago

Are there any news on this issue? Being able to execute multiple SQL statements in one tab/window would be quite nice.

Alecaddd commented 6 years ago

I'm working on this and it should be out around version 0.6 or similar. I'm trying to keep a sort of organized roadmap of the futures I'm implementing.

diethardsteiner commented 6 years ago

ok thanks for letting me know! I am looking forward to this release then.

pktiuk commented 3 years ago

I still have this problem, but 0.6 has already been released.

create table tab1 (
xxxxxx int
);

drop table tab1;
ar0ra1 commented 3 years ago

It's quite an old issue, and I haven't seen the implementation since then. But, Why not build an array of queries? Split the string queries via delimiter (i.e., ";") Add to the queue and execute queries in the series?

@Alecaddd this was for the implementation

pktiuk commented 3 years ago

Maybe I misunderstood something, this description seemed to match my issue.

Split the string queries via delimiter (i.e., ";")

That's what I am doing.

I put multiple strings with queries in one query, I try to execute it, but only the last query is executed. image

Alecaddd commented 3 years ago

Sequeler doesn't currently support running multiple queries at once, I need to work on that feature. You can, for now, put your cursor on the first string, run the query, then move the cursor to the last string and run the query again.

Basically, for now, Sequeler runs the only the string that starts from an empty line or new line, until the end of the document or a semicolon.

pktiuk commented 3 years ago

I need to work on that feature.

If it is a thing to implement maybe this issue should be reopened? To mark it as a something to be done.

freaktechnik commented 2 years ago

Kind of related to this: it'd be nice if you could run an entire .sql file from Sequeler.