Skip to content

Add \ne to edit a named query in the external editor - #1609

Merged
j-bennet merged 2 commits into
dbcli:mainfrom
DiegoDAF:feature/ne-edit-named-query
Aug 3, 2026
Merged

Add \ne to edit a named query in the external editor#1609
j-bennet merged 2 commits into
dbcli:mainfrom
DiegoDAF:feature/ne-edit-named-query

Conversation

@DiegoDAF

Copy link
Copy Markdown
Contributor

Summary

Adds \ne <name>, a special command to edit a named query in the external editor ($EDITOR).

It loads the named query's SQL into the editor and, on save, writes the edited result back to the [named queries] section of the config (creating the entry if it does not exist). This complements \ns (save) by making it practical to edit longer named queries without retyping them, mirroring how \e / \ev / \ef already open the editor.

Addresses the editor part of #1430.

Behavior

  • \ne foo on an existing query: opens it in $EDITOR; saving updates it.
  • \ne foo on a new name: opens an empty editor; saving creates it.
  • Empty result or no changes: nothing is saved (reported in the status).

Tests

  • tests/test_main.py::test_edit_named_query covers create / update / no-change / empty / editor-error / usage (editor mocked, no DB needed).

Changelog

  • Added an entry under a new Upcoming section.

\ne <name> loads a named query's SQL into $EDITOR and writes the edited
result back to the [named queries] section on save, creating it if it does
not exist. Complements \ns for editing longer queries. Addresses the
editor part of issue dbcli#1430.
@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@DiegoDAF

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 117449b1a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ed-query

# Conflicts:
#	AUTHORS
#	changelog.rst
@j-bennet

j-bennet commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Thank you @DiegoDAF .

@j-bennet
j-bennet merged commit 5d5e082 into dbcli:main Aug 3, 2026
13 of 22 checks passed
DiegoDAF added a commit to DiegoDAF/pgcli.daf that referenced this pull request Aug 3, 2026
diego-feito-stori pushed a commit to DiegoDAF/pgcli.daf that referenced this pull request Aug 11, 2026
The "edit sql in file with external editor" scenario errors intermittently on
slow CI runners: pexpect's expect_exact waited only 2 seconds for the ex-mode
banner. It has bitten upstream's CI repeatedly (PRs dbcli#1543/dbcli#1544/dbcli#1609) and now
our fork's CI on main (cee716d run: unit 3139 passed, 61 scenarios passed, the
only error was this scenario on 3.10 while 3.11 was fully green).

All expect timeouts in iocommands.py bumped to 10s. Passing runs are not
slowed: pexpect returns as soon as the expected text appears; the timeout only
bounds how long a FAILING wait lasts.

Verified locally: behave features/iocommands.feature green against a throwaway
PG (2 scenarios, 12 steps). Same patch offered to upstream in the dbcli#1543 review
thread.
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.

2 participants