Skip to content

Commit 0ad3393

Browse files
authored
confirm_destructive_query: Use confirm rather than prompt (#1410)
* confirm_destructive_query: Use confirm rather than prompt * Fix tests
1 parent 13ca7d2 commit 0ad3393

File tree

5 files changed

+6
-4
lines changed

5 files changed

+6
-4
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ Contributors:
129129
* Damien Baty (dbaty)
130130
* blag
131131
* Rob Berry (rob-b)
132+
* Sharon Yogev (sharonyogev)
132133

133134
Creator:
134135
--------

changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Bug fixes:
3232
predetermined table aliases instead of generating aliases programmatically on
3333
the fly
3434
* Fixed SQL error when there is a comment on the first line: ([issue 1403](https://github.com/dbcli/pgcli/issues/1403))
35+
* Fix wrong usage of prompt instead of confirm when confirm execution of destructive query
3536

3637
Internal:
3738
---------

pgcli/packages/prompt_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ def confirm_destructive_query(queries, keywords, alias):
1616
if alias:
1717
info += f" in {click.style(alias, fg='red')}"
1818

19-
prompt_text = f"{info}.\nDo you want to proceed? (y/n)"
19+
prompt_text = f"{info}.\nDo you want to proceed?"
2020
if is_destructive(queries, keywords) and sys.stdin.isatty():
21-
return prompt(prompt_text, type=bool)
21+
return confirm(prompt_text)
2222

2323

2424
def confirm(*args, **kwargs):

tests/features/steps/basic_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def step_resppond_to_destructive_command(context, response):
206206
"""Respond to destructive command."""
207207
wrappers.expect_exact(
208208
context,
209-
"You're about to run a destructive command.\r\nDo you want to proceed? (y/n):",
209+
"You're about to run a destructive command.\r\nDo you want to proceed? [y/N]:",
210210
timeout=2,
211211
)
212212
context.cli.sendline(response.strip())

tests/features/steps/expanded.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def step_prepare_data(context):
1616
context.cli.sendline("drop table if exists a;")
1717
wrappers.expect_exact(
1818
context,
19-
"You're about to run a destructive command.\r\nDo you want to proceed? (y/n):",
19+
"You're about to run a destructive command.\r\nDo you want to proceed? [y/N]:",
2020
timeout=2,
2121
)
2222
context.cli.sendline("y")

0 commit comments

Comments
 (0)