diff options
author | Roland Walker <walker@pobox.com> | 2021-01-07 09:51:06 -0500 |
---|---|---|
committer | Roland Walker <walker@pobox.com> | 2021-01-07 09:53:50 -0500 |
commit | 7273ea54062ebb787fee76bce2df9bedcf3c2d75 (patch) | |
tree | 9062b5a6a546f7e9f980716f64e43192795b4b05 | |
parent | dcb70adadea408ebfa380f6b0e81b8d3ab4a57d0 (diff) |
allow backtick quoting around "use" argument
-rw-r--r-- | changelog.md | 1 | ||||
-rwxr-xr-x | mycli/main.py | 3 | ||||
-rw-r--r-- | test/features/crud_database.feature | 4 | ||||
-rw-r--r-- | test/features/steps/crud_database.py | 8 |
4 files changed, 16 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md index 02f53cc..b0cee23 100644 --- a/changelog.md +++ b/changelog.md @@ -21,6 +21,7 @@ Bug Fixes: * Fix \once -o to overwrite output whole, instead of line-by-line. * Dispatch lines ending with `\e` or `\clip` on return, even in multiline mode. * Restore working local `--socket=<UDS>` (Thanks: [xeron]). +* Allow backtick quoting around the database argument to the `use` command. 1.22.2 ====== diff --git a/mycli/main.py b/mycli/main.py index c66d048..3e4917e 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -239,6 +239,9 @@ class MyCli(object): ) return + if arg.startswith('`') and arg.endswith('`'): + arg = re.sub(r'^`(.*)`$', r'\1', arg) + arg = re.sub(r'``', r'`', arg) self.sqlexecute.change_db(arg) yield (None, None, None, 'You are now connected to database "%s" as ' diff --git a/test/features/crud_database.feature b/test/features/crud_database.feature index 0c298b6..f4a7a7f 100644 --- a/test/features/crud_database.feature +++ b/test/features/crud_database.feature @@ -16,6 +16,10 @@ Feature: manipulate databases: when we connect to dbserver then we see database connected + Scenario: connect and disconnect from quoted test database + When we connect to quoted test database + then we see database connected + Scenario: create and drop default database When we create database then we see database created diff --git a/test/features/steps/crud_database.py b/test/features/steps/crud_database.py index be6dec0..841f37d 100644 --- a/test/features/steps/crud_database.py +++ b/test/features/steps/crud_database.py @@ -37,6 +37,14 @@ def step_db_connect_test(context): context.cli.sendline('use {0};'.format(db_name)) +@when('we connect to quoted test database') +def step_db_connect_quoted_tmp(context): + """Send connect to database.""" + db_name = context.conf['dbname'] + context.currentdb = db_name + context.cli.sendline('use `{0}`;'.format(db_name)) + + @when('we connect to tmp database') def step_db_connect_tmp(context): """Send connect to database.""" |