Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confirm_destructive_query: Use confirm rather than prompt #1410

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

sharonyogev
Copy link
Contributor

Description

Until now, the destructive query prompt, which is a great feature, uses click prompt with type=bool to confirm the query, those resulting weird behavior such:

postgres@localhost:tests> UPDATE test SET id=0;
You're about to run a destructive command.
Do you want to proceed? (y/n): t
Your call!
UPDATE 0
Time: 0.014s
postgres@localhost:tests>

This is because it capture t/true as yes and f/false as no, for example

I think we should use click confirm which is more suitable for this action
We can use it with default to "No" or without a default and force the user to enter

postgres@localhost:tests> UPDATE test SET id=0;
You're about to run a destructive command.
Do you want to proceed? [y/N]: t
Error: invalid input
You're about to run a destructive command.
Do you want to proceed? [y/N]:
Wise choice!
cancelled query
postgres@localhost:tests>

Checklist

  • I've added this contribution to the changelog.rst.
  • I've added my name to the AUTHORS file (or it's already there).
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install), and ran black on my code.
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

@sharonyogev sharonyogev force-pushed the fix/use_confirm_instead_of_prompt branch from 3d5a429 to 6f63ae1 Compare October 17, 2023 18:09
@sharonyogev
Copy link
Contributor Author

Thanks @j-bennet fixed the tests

@codecov-commenter
Copy link

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (13ca7d2) 79.57% compared to head (6f63ae1) 79.53%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1410      +/-   ##
==========================================
- Coverage   79.57%   79.53%   -0.04%     
==========================================
  Files          25       25              
  Lines        3035     3035              
==========================================
- Hits         2415     2414       -1     
- Misses        620      621       +1     
Files Coverage Δ
pgcli/packages/prompt_utils.py 70.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sharonyogev
Copy link
Contributor Author

@j-bennet Hi, the failure on 3.12 does not look like it's related to my change (Timeout exceeded), any idea? Thanks

@j-bennet j-bennet merged commit 0ad3393 into dbcli:main Oct 18, 2023
7 checks passed
@j-bennet
Copy link
Contributor

j-bennet commented Oct 18, 2023

@sharonyogev Integration tests can be flaky; I re-ran and now it's fine. Thank you for the PR.

@sharonyogev
Copy link
Contributor Author

@j-bennet Yay!! Thanks 🙏

@sharonyogev sharonyogev deleted the fix/use_confirm_instead_of_prompt branch October 30, 2023 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants