-
Notifications
You must be signed in to change notification settings - Fork 662
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
implemented DELIMITER command #782
Conversation
Codecov Report
@@ Coverage Diff @@
## master #782 +/- ##
==========================================
+ Coverage 77.94% 78.29% +0.34%
==========================================
Files 25 26 +1
Lines 2403 2460 +57
==========================================
+ Hits 1873 1926 +53
- Misses 530 534 +4
Continue to review full report at Codecov.
|
Nice work though, it seems pretty thorough! |
The delimiter is changed from the default (;) when you want to create functions that have semi-colons in them. This stackoverflow answer does a better job of explaining it. |
@pasenor Do you want to take a stab at implementing it as part of the special commands package? When I try out the feature I see |
Makes sense, but we still need to somehow let the |
As @amjith said, the only use case is declaring stored procedures with |
mmm, I never used stored procedures in mysql, sounds like a valid use case... |
This works great! I like how thorough the tests are done for this feature. 🥇 |
nicely done @pasenor ! |
Description
#383
DELIMITER command to switch the default delimiter
;
to something else. Copied the behavior from the standard mysql shell.Splitting lines is based on a suggestion by @srittau as a temporary workaround until custom delimiters get into the sqlparse library
One limitation is that delimiter cannot be used in a favorite query, for example if you save
then
\f foo
will result in a syntax error, although a user may actually want to save such a query, e.g. to do some work on stored procedures. I can imagine refactoring favorite queries so that they are executed withSQLExecute
, then all special commands will be available, but I'm not sure if it's worth the trouble.UPD: ah, I see Thomas has been doing some work towards special commands is favorite queries in #600 so it's probably better to handle there.
Another concern is that I have changed the API of
_multiline_exception
(it now accepts the delimiter argument), which is one more difference from pgcli and the rest of the dbcli tools.And generally, though having delimiter switching may be useful to people accustomed to the default mysql shell, it's primary purpose is to deal with stored procedures. Maybe it would be more straightforward to implement a simple call stack, so we can track BEGIN - END statements directly?
Checklist
changelog.md
.AUTHORS
file (or it's already there).