Re: psql: Allow editing query results with \gedit

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: psql: Allow editing query results with \gedit
Дата
Msg-id CAKFQuwYzHrqCPp2PYvvp3p7fKakg9ZTHdgniCFReFZ9LraQbqg@mail.gmail.com
обсуждение исходный текст
Ответ на psql: Allow editing query results with \gedit  (Christoph Berg <myon@debian.org>)
Ответы Re: psql: Allow editing query results with \gedit  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: psql: Allow editing query results with \gedit  (Christoph Berg <myon@debian.org>)
Список pgsql-hackers
On Mon, Jan 22, 2024 at 8:06 AM Christoph Berg <myon@debian.org> wrote:
Assuming a SELECT statement reading from a single table, it is quite an
effort to transform that statement to an UPDATE statement on that table,
perhaps to fix a typo that the user has spotted in the query result.


Building off the other comments, I'd suggest trying to get rid of the intermediate JSOn format and also just focus on a single row at any given time.

For an update the first argument to the metacommand could be the unique key value present in the previous result.  The resultant UPDATE would just put that into the where clause and every other column in the result would be a SET clause column with the thing being set the current value, ready to be edited.

DELETE would be similar but without the need for a SET clause.

INSERT can produce a template INSERT (cols) VALUES ... command with some smarts regarding auto incrementing keys and placeholder values.

David J.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Support TZ format code in to_timestamp()
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pg_stat_statements and "IN" conditions