summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeamile <lanhuermao@gmail.com>2021-01-10 16:11:24 +0800
committerGitHub <noreply@github.com>2021-01-10 16:11:24 +0800
commitc639a5adf636627c904cd6ccda49407b2affd10c (patch)
tree0f4af200b889f19cd2788bc83c641e8ccd74d7d7
parent98a6b5b43477fb98719d0ad5d61ffffa459f235c (diff)
parent8cb69754b9a50fe843fc6851055893a9dd6217f8 (diff)
Merge branch 'master' into add-commandline-option-charset
-rw-r--r--.github/workflows/ci.yml10
-rw-r--r--README.md6
-rw-r--r--changelog.md3
-rw-r--r--mycli/AUTHORS1
-rwxr-xr-xmycli/main.py20
-rw-r--r--test/features/crud_database.feature4
-rw-r--r--test/features/steps/crud_database.py8
7 files changed, 34 insertions, 18 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index aad35d9..413b749 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,9 +1,7 @@
name: mycli
on:
- push:
- branches-ignore:
- - 'master'
+ pull_request:
paths-ignore:
- '**.md'
@@ -14,7 +12,7 @@ jobs:
strategy:
matrix:
- python-version: [3.6, 3.7, 3.8]
+ python-version: [3.6, 3.7, 3.8, 3.9]
steps:
@@ -48,10 +46,8 @@ jobs:
./setup.py test --pytest-args="--cov-report= --cov=mycli"
- name: Lint
- env:
- GIT_BRANCH: ${{ github.ref }}
run: |
- ./setup.py lint --branch="$GIT_BRANCH"
+ ./setup.py lint --branch=HEAD
- name: Coverage
run: |
diff --git a/README.md b/README.md
index 47efe5f..c709eb8 100644
--- a/README.md
+++ b/README.md
@@ -63,8 +63,8 @@ $ sudo apt-get install mycli # Only on debian or ubuntu
--ssh-password TEXT Password to connect to ssh server.
--ssh-key-filename TEXT Private key filename (identify file) for the
ssh connection.
- --ssh-config-path TEXT Path to ssh configuation.
- --ssh-config-host TEXT Host for ssh server in ssh configuations (requires paramiko).
+ --ssh-config-path TEXT Path to ssh configuration.
+ --ssh-config-host TEXT Host for ssh server in ssh configurations (requires paramiko).
--ssl-ca PATH CA file in PEM format.
--ssl-capath TEXT CA directory.
--ssl-cert PATH X509 cert in PEM format.
@@ -114,7 +114,7 @@ Features
* Support for multiline queries.
* Favorite queries with optional positional parameters. Save a query using
`\fs alias query` and execute it with `\f alias` whenever you need.
-* Timing of sql statments and table rendering.
+* Timing of sql statements and table rendering.
* Config file is automatically created at ``~/.myclirc`` at first launch.
* Log every query and its results to a file (disabled by default).
* Pretty prints tabular data (with colors!)
diff --git a/changelog.md b/changelog.md
index b379e83..acf434b 100644
--- a/changelog.md
+++ b/changelog.md
@@ -21,6 +21,9 @@ 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/AUTHORS b/mycli/AUTHORS
index 86a60aa..221ce8b 100644
--- a/mycli/AUTHORS
+++ b/mycli/AUTHORS
@@ -80,6 +80,7 @@ Contributors:
* Massimiliano Torromeo
* Roland Walker
* xeron
+ * 0xflotus
* Seamile
Creator:
diff --git a/mycli/main.py b/mycli/main.py
index 77abc75..cbc1858 100755
--- a/mycli/main.py
+++ b/mycli/main.py
@@ -21,7 +21,7 @@ from cli_helpers.tabular_output import preprocessors
from cli_helpers.utils import strip_ansi
import click
import sqlparse
-from mycli.packages.parseutils import is_dropping_database
+from mycli.packages.parseutils import is_dropping_database, is_destructive
from prompt_toolkit.completion import DynamicCompleter
from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
from prompt_toolkit.key_binding.bindings.named_commands import register as prompt_register
@@ -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 '
@@ -1257,14 +1260,15 @@ def cli(database, user, host, port, socket, password, dbname,
click.secho('Sorry... :(', err=True, fg='red')
exit(1)
- try:
- sys.stdin = open('/dev/tty')
- except (IOError, OSError):
- mycli.logger.warning('Unable to open TTY as stdin.')
+ if mycli.destructive_warning and is_destructive(stdin_text):
+ try:
+ sys.stdin = open('/dev/tty')
+ warn_confirmed = confirm_destructive_query(stdin_text)
+ except (IOError, OSError):
+ mycli.logger.warning('Unable to open TTY as stdin.')
+ if not warn_confirmed:
+ exit(0)
- if (mycli.destructive_warning and
- confirm_destructive_query(stdin_text) is False):
- exit(0)
try:
new_line = True
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."""