Skip to content

Commit

Permalink
confirm_destructive_query: Use confirm rather than prompt (#1410)
Browse files Browse the repository at this point in the history
* confirm_destructive_query: Use confirm rather than prompt

* Fix tests
  • Loading branch information
sharonyogev committed Oct 18, 2023
1 parent 13ca7d2 commit 0ad3393
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Contributors:
* Damien Baty (dbaty)
* blag
* Rob Berry (rob-b)
* Sharon Yogev (sharonyogev)

Creator:
--------
Expand Down
1 change: 1 addition & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
---------
Expand Down
4 changes: 2 additions & 2 deletions pgcli/packages/prompt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/features/steps/basic_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion tests/features/steps/expanded.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 0ad3393

Please sign in to comment.