[PATCH] Tab completion for ALTER TABLE … ADD …

Started by Dagfinn Ilmari Mannsåkerover 4 years ago8 messageshackers
Jump to latest

Hi Hackers,

The other day I noticed that there's no tab completion after ALTER TABLE
… ADD, so here's a patch. In addition to COLUMN and all the table
constraint types, it also completes with the list of unique indexes on
the table after ALTER TABLE … ADD … USING INDEX.

- ilmari

Attachments:

0001-Add-tab-completion-for-ALTER-TABLE-ADD.patchtext/x-diffDownload+44-1
In reply to: Dagfinn Ilmari Mannsåker (#1)
Re: [PATCH] Tab completion for ALTER TABLE … ADD …

ilmari@ilmari.org (Dagfinn Ilmari Mannsåker) writes:

Hi Hackers,

The other day I noticed that there's no tab completion after ALTER TABLE
… ADD, so here's a patch. In addition to COLUMN and all the table
constraint types, it also completes with the list of unique indexes on
the table after ALTER TABLE … ADD … USING INDEX.

Added to the 2021-09 commitfest: https://commitfest.postgresql.org/34/3280/

- ilmari

#3Michael Paquier
michael@paquier.xyz
In reply to: Dagfinn Ilmari Mannsåker (#1)
Re: [PATCH] Tab completion for ALTER TABLE … ADD …

On Tue, Aug 03, 2021 at 12:48:38PM +0100, Dagfinn Ilmari Mannsåker wrote:

The other day I noticed that there's no tab completion after ALTER TABLE
… ADD, so here's a patch. In addition to COLUMN and all the table
constraint types, it also completes with the list of unique indexes on
the table after ALTER TABLE … ADD … USING INDEX.

I was reading this patch (not actually tested), and that's a clear
improvement. One extra thing that could be done here is to complete
with types for a ALTER TABLE ADD COLUMN foo. We could as well have a
list of columns after UNIQUE or PRIMARY KEY, but that feels like extra
cream on top of the cake. In short I am fine with what you have
here.
--
Michael

In reply to: Michael Paquier (#3)
Re: [PATCH] Tab completion for ALTER TABLE … ADD …

Michael Paquier <michael@paquier.xyz> writes:

On Tue, Aug 03, 2021 at 12:48:38PM +0100, Dagfinn Ilmari Mannsåker wrote:

The other day I noticed that there's no tab completion after ALTER TABLE
… ADD, so here's a patch. In addition to COLUMN and all the table
constraint types, it also completes with the list of unique indexes on
the table after ALTER TABLE … ADD … USING INDEX.

I was reading this patch (not actually tested), and that's a clear
improvement. One extra thing that could be done here is to complete
with types for a ALTER TABLE ADD COLUMN foo.

That was easy enough to add (just a bit of extra fiddling to handle
COLUMN being optional), done in the attached v2 patch.

We could as well have a list of columns after UNIQUE or PRIMARY KEY,
but that feels like extra cream on top of the cake.

Doing a list of arbitrarily many comma-separated names is more
complicated, so that can be the subject for another patch.

In short I am fine with what you have here.

Thanks for the review.

- ilmari

Attachments:

v2-0001-Add-tab-completion-for-ALTER-TABLE-ADD.patchtext/x-diffDownload+49-1
#5Michael Paquier
michael@paquier.xyz
In reply to: Dagfinn Ilmari Mannsåker (#4)
Re: [PATCH] Tab completion for ALTER TABLE … ADD …

On Fri, Aug 27, 2021 at 11:52:33AM +0100, Dagfinn Ilmari Mannsåker wrote:

That was easy enough to add (just a bit of extra fiddling to handle
COLUMN being optional), done in the attached v2 patch.

This part was a bit misleading, as it would recommend a list of types
when specifying just ADD CONSTRAINT for example, so I have removed
it. An extra thing that felt a bit overdoing is the addition of KEY
after PRIMARY/FOREIGN.

Doing a list of arbitrarily many comma-separated names is more
complicated, so that can be the subject for another patch.

No objections to that. I have applied what we have now, as that's
already an improvement.
--
Michael

In reply to: Michael Paquier (#5)
Re: [PATCH] Tab completion for ALTER TABLE … ADD …

Michael Paquier <michael@paquier.xyz> writes:

On Fri, Aug 27, 2021 at 11:52:33AM +0100, Dagfinn Ilmari Mannsåker wrote:

That was easy enough to add (just a bit of extra fiddling to handle
COLUMN being optional), done in the attached v2 patch.

This part was a bit misleading, as it would recommend a list of types
when specifying just ADD CONSTRAINT for example, so I have removed
it.

That was because I forgot to exclude all the other object types that can
come after ADD. Attached is a patch that does that. I also moved it
right next to the ALTER TABLE … ADD completion, and added a comment to
keep the two lists in sync.

An extra thing that felt a bit overdoing is the addition of KEY after
PRIMARY/FOREIGN.

Yeah, I guess people are unlikely to write out the whole PRIMARY or FOREIGN
and only then hit tab to complete the rest.

Doing a list of arbitrarily many comma-separated names is more
complicated, so that can be the subject for another patch.

No objections to that. I have applied what we have now, as that's
already an improvement.

Thanks!

- ilmari

Attachments:

0001-Complete-type-names-after-ALTER-TABLE-ADD-COLUMN.patchtext/x-diffDownload+6-1
#7Michael Paquier
michael@paquier.xyz
In reply to: Dagfinn Ilmari Mannsåker (#6)
Re: [PATCH] Tab completion for ALTER TABLE … ADD …

On Mon, Aug 30, 2021 at 02:38:19PM +0100, Dagfinn Ilmari Mannsåker wrote:

That was because I forgot to exclude all the other object types that can
come after ADD. Attached is a patch that does that. I also moved it
right next to the ALTER TABLE … ADD completion, and added a comment to
keep the two lists in sync.

Looks fine to me, so applied while we are on it.
--
Michael

In reply to: Michael Paquier (#7)
Re: [PATCH] Tab completion for ALTER TABLE … ADD …

On Tue, 31 Aug 2021, at 04:20, Michael Paquier wrote:

On Mon, Aug 30, 2021 at 02:38:19PM +0100, Dagfinn Ilmari Mannsåker wrote:

That was because I forgot to exclude all the other object types that can
come after ADD. Attached is a patch that does that. I also moved it
right next to the ALTER TABLE … ADD completion, and added a comment to
keep the two lists in sync.

Looks fine to me, so applied while we are on it.

Thanks!

- ilmari