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

Unable to execute multiple lines of MySQL commands #658

Open
kotori2 opened this issue Dec 14, 2020 · 5 comments
Open

Unable to execute multiple lines of MySQL commands #658

kotori2 opened this issue Dec 14, 2020 · 5 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request

Comments

@kotori2
Copy link
Contributor

kotori2 commented Dec 14, 2020

Describe the bug
Syntax error when I trying to execute multiple lines of MySQL commands.

libc++abi.dylib: terminating with uncaught exception of type drogon::orm::SqlError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SHOW TABLES' at line 2

To Reproduce

auto cli = drogon::orm::DbClient::newMysqlClient("blahblah");
cli->execSqlSync(R"EOF(
SHOW TABLES;
SHOW TABLES;
)EOF");

Expected behavior
SQL command executed without error or the framework could provide another multi line SQL interface.

Screenshots
NA

Desktop (please complete the following information):
NA

Smartphone (please complete the following information):
NA

Additional context

% mysql --version
mysql  Ver 8.0.19 for osx10.15 on x86_64 (Homebrew)

Dragon v1.1.0 release

@an-tao
Copy link
Member

an-tao commented Dec 15, 2020

This is duplicated with the issue #582. should we find a resolution for this? @rbugajewski

@an-tao an-tao added the duplicate This issue or pull request already exists label Dec 15, 2020
@rbugajewski
Copy link
Collaborator

I’m not sure. I think we got this issue about 2–3x in the last couple of months, so people definitely have some need for running multiple SQL commands at once. But on the other side I wonder if for all of these issues, just splitting the commands wasn’t perfectly fine.

Maybe we should update the docs to more explicitly mention this behavior?

@rbugajewski
Copy link
Collaborator

@kotori2 What was your specific use case? The example you attached to this issue seems to be made up for the sake of simplification. Do you do something in your code that would be easily possible by splitting up multiple commands?

@kotori2
Copy link
Contributor Author

kotori2 commented Dec 15, 2020

@rbugajewski My use case is to automatically handle database structure initialization / upgrade, I just execute a 500 lines SQL files to create all tables.
Of course I can split them into several commands, but I think it's relatively less efficient? I just need to execute commands and no response parsing required. Not sure if MySQL provide interface for multi-line SQL command tho.

@rbugajewski
Copy link
Collaborator

@kotori2 I see, thanks for the explanation.

I think such functionality would greatly fit into a database migration plugin for Drogon, but there will be changes necessary in the framework, too. The plugin would have to model the transitive transitions between database model versions (migration to newer version & rollback to older version).

@rbugajewski rbugajewski added the enhancement New feature or request label Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants