Skip to content

Commit 5900a08

Browse files
authored
Allow force-quit if a transaction is running (#1573)
* allow force-quit if a transaction is running Signed-off-by: maximsmol <1472826+maximsmol@users.noreply.github.com> * update changelog Signed-off-by: maximsmol <1472826+maximsmol@users.noreply.github.com> --------- Signed-off-by: maximsmol <1472826+maximsmol@users.noreply.github.com>
1 parent 4adbdb1 commit 5900a08

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Features:
77
* Add cursor shape support for vi mode. When ``vi = True``, the terminal cursor now
88
reflects the current editing mode: beam in INSERT, block in NORMAL, underline in REPLACE.
99
Uses prompt_toolkit's ``ModalCursorShapeConfig``.
10+
* Add the option to force-quit pgcli when a transaction is in progress.
1011
* Add support of Python 3.14.
1112
* Drop support of Python 3.9.
1213

pgcli/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ def _check_ongoing_transaction_and_allow_quitting(self):
933933
while 1:
934934
try:
935935
choice = click.prompt(
936-
"A transaction is ongoing. Choose `c` to COMMIT, `r` to ROLLBACK, `a` to abort exit.",
936+
"A transaction is ongoing. Choose `c` to COMMIT, `r` to ROLLBACK, `a` to abort exit, `force` to exit anyway.",
937937
default="a",
938938
)
939939
except click.Abort:
@@ -945,6 +945,8 @@ def _check_ongoing_transaction_and_allow_quitting(self):
945945
choice = choice.lower()
946946
if choice == "a":
947947
return False # do not quit
948+
if choice == "force":
949+
return True # quit anyway
948950
if choice == "c":
949951
query = self.execute_command("commit")
950952
return query.successful # quit only if query is successful

0 commit comments

Comments
 (0)