summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSharon Yogev <31185192+sharonyogev@users.noreply.github.com>2023-10-18 19:25:29 +0300
committerGitHub <noreply@github.com>2023-10-18 09:25:29 -0700
commit0ad3393fa83de6251ea07d938835f7fc5f0624f0 (patch)
tree24ade7dbc1b8965a393a07986c75652912094e97
parent13ca7d24303c0c03eeecb8471ea34af818e35068 (diff)
confirm_destructive_query: Use confirm rather than prompt (#1410)
* confirm_destructive_query: Use confirm rather than prompt * Fix tests
-rw-r--r--AUTHORS1
-rw-r--r--changelog.rst1
-rw-r--r--pgcli/packages/prompt_utils.py4
-rw-r--r--tests/features/steps/basic_commands.py2
-rw-r--r--tests/features/steps/expanded.py2
5 files changed, 6 insertions, 4 deletions
diff --git a/AUTHORS b/AUTHORS
index a4eac9de..5eff7db5 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -129,6 +129,7 @@ Contributors:
* Damien Baty (dbaty)
* blag
* Rob Berry (rob-b)
+ * Sharon Yogev (sharonyogev)
Creator:
--------
diff --git a/changelog.rst b/changelog.rst
index 5825675a..3822eae0 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -32,6 +32,7 @@ Bug fixes:
predetermined table aliases instead of generating aliases programmatically on
the fly
* Fixed SQL error when there is a comment on the first line: ([issue 1403](https://github.com/dbcli/pgcli/issues/1403))
+* Fix wrong usage of prompt instead of confirm when confirm execution of destructive query
Internal:
---------
diff --git a/pgcli/packages/prompt_utils.py b/pgcli/packages/prompt_utils.py
index 86363204..997b86e7 100644
--- a/pgcli/packages/prompt_utils.py
+++ b/pgcli/packages/prompt_utils.py
@@ -16,9 +16,9 @@ def confirm_destructive_query(queries, keywords, alias):
if alias:
info += f" in {click.style(alias, fg='red')}"
- prompt_text = f"{info}.\nDo you want to proceed? (y/n)"
+ prompt_text = f"{info}.\nDo you want to proceed?"
if is_destructive(queries, keywords) and sys.stdin.isatty():
- return prompt(prompt_text, type=bool)
+ return confirm(prompt_text)
def confirm(*args, **kwargs):
diff --git a/tests/features/steps/basic_commands.py b/tests/features/steps/basic_commands.py
index 8f184bbd..687bdc0a 100644
--- a/tests/features/steps/basic_commands.py
+++ b/tests/features/steps/basic_commands.py
@@ -206,7 +206,7 @@ def step_resppond_to_destructive_command(context, response):
"""Respond to destructive command."""
wrappers.expect_exact(
context,
- "You're about to run a destructive command.\r\nDo you want to proceed? (y/n):",
+ "You're about to run a destructive command.\r\nDo you want to proceed? [y/N]:",
timeout=2,
)
context.cli.sendline(response.strip())
diff --git a/tests/features/steps/expanded.py b/tests/features/steps/expanded.py
index ac84c41c..302cab94 100644
--- a/tests/features/steps/expanded.py
+++ b/tests/features/steps/expanded.py
@@ -16,7 +16,7 @@ def step_prepare_data(context):
context.cli.sendline("drop table if exists a;")
wrappers.expect_exact(
context,
- "You're about to run a destructive command.\r\nDo you want to proceed? (y/n):",
+ "You're about to run a destructive command.\r\nDo you want to proceed? [y/N]:",
timeout=2,
)
context.cli.sendline("y")