Repository navigation
Support DELIMITER in batch input - #2430
Conversation
|
Hi! Thanks! This issue is first in https://github.com/dbcli/mycli/blob/main/doc/known_bugs.md#custom-delimiters, and there are other places custom delimiters are ignored. Unfortunately merging #2429 created a merge conflict here; can you fix it? Or should I? |
| statements += batch_text | ||
| if delimiter != ';': | ||
| statement = statements.rstrip() | ||
| if statement.endswith(delimiter): |
There was a problem hiding this comment.
A comment is probably warranted regarding the limitation that the custom delimiter may only be recognized at EOL.
There was a problem hiding this comment.
Added a comment there in 23a3762: the custom delimiter is only recognized at the end of a line, so two statements on one line go out as one.
32e7aeb to
23a3762
Compare
|
@rolandwalker rebased onto main and fixed the changelog conflict in 23a3762. Tests pass. |
|
Sweet! Thanks! |
|
Released in https://github.com/dbcli/mycli/releases/tag/v2.31.0 ! |
Description
mycli < file.sqland--batchsplit the input on;only, so anyDELIMITERblock fails. Amysqldump/mariadb-dumpfile with a trigger or routine stops at the first one:and the rest of the dump never runs. A script with a procedure:
fails with
(1064, "... near '' at line 3").statements_from_filehandlenow treats aDELIMITER xline as a client command, the way themysqlclient does: it switches the delimiter and isn't sent. While the delimiter isn't;, lines are collected until the text ends with it, and the statement is yielded without it. Input with the default;goes through the existing sqlglot/sqlparse path unchanged.Tested: a new
test_batch_utils.pycase fails without the change.pytest mycli_test/pytests: 3354 passed with the change and 3353 on main, with the same 62 failures on both (tests that need a live server here). Against MariaDB 11: the dump above restores with its trigger (none restored on main), and the script printsin procand runs the statements after it.ruff check,ruff formatandmypy --install-types .clean.Checklist
changelog.mdfile.mycli/AUTHORS.txtfile (or it's already there).