summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2021-01-07 21:04:46 -0800
committerGitHub <noreply@github.com>2021-01-07 21:04:46 -0800
commit8cb69754b9a50fe843fc6851055893a9dd6217f8 (patch)
tree3a7363f6e9837c519fec29481693fc12fb87dbaf
parent68680b6a94796201991b20099f1aa6072282e594 (diff)
parentca17e5f83d47a34784d75f0904038235b932ed4d (diff)
Merge pull request #936 from dbcli/RW/use-quote-db-name
Allow backtick quoting around the database argument to the `use` command
-rw-r--r--changelog.md2
-rwxr-xr-xmycli/main.py3
-rw-r--r--test/features/crud_database.feature4
-rw-r--r--test/features/steps/crud_database.py8
4 files changed, 16 insertions, 1 deletions
diff --git a/changelog.md b/changelog.md
index 4b2565e..fe8e284 100644
--- a/changelog.md
+++ b/changelog.md
@@ -21,10 +21,10 @@ 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.
* Avoid opening `/dev/tty` when `--no-warn` is given.
* Fixed some typo errors in `README.md`.
-
1.22.2
======
diff --git a/mycli/main.py b/mycli/main.py
index 627fcb9..f026110 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."""