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

[enhancement] Ignore column by name #135

Closed
tobwen opened this issue May 4, 2020 · 9 comments
Closed

[enhancement] Ignore column by name #135

tobwen opened this issue May 4, 2020 · 9 comments

Comments

@tobwen
Copy link

tobwen commented May 4, 2020

tl;dr of the request

It would be great to ignore columns by name with wildcards like this: pspg --ignore-columns '*geom*'

background

I'm using pspg as pager inside PostgreSQL (good work!) and I'm working with geodata. The pager, of course, tries to display the binary geodata column, when doing a SELECT * FROM table. When this column is at the very beginning, the user needs to right-scroll for a while.

Instead of selecting every single column (PostgreSQL doesn't allow SELECT *, -geom), it would be very nice to just ignore the column. Additional setup, activation, and de-activation via menu would be the ultimate solution.

@tobwen tobwen changed the title [request] Ignore column by name [enhancement] Ignore column by name May 5, 2020
@okbob
Copy link
Owner

okbob commented May 5, 2020

It is interesting task, but it is not simply - because Postgres is pager only and usually just display content formatted by another application, I think it can be possible to implement in CSV format, where pspg does formatting too.

@okbob
Copy link
Owner

okbob commented May 5, 2020

I implemented proof concept - final solution (more dynamic) needs significantly more work. But I think so this "initial" design can be useful too - with some psql ":" macros:

\setenv PSPG '--csv-header on --skip-columns-like=okres_id --csv'
\pset format csv
select ...
\unset PSPG

Please check

@okbob
Copy link
Owner

okbob commented May 5, 2020

Wildcards are not supported, but by default substring test is used. It can be changed by RE symbols ^ or $.

@tobwen
Copy link
Author

tobwen commented May 5, 2020

Thanks, it works!

@tobwen
Copy link
Author

tobwen commented May 5, 2020

Hehe, another enhancement: maybe add a list? --skip-columns-like=a,b,c

Edit:
Please check your inbox and order yourself some pizza.

@okbob
Copy link
Owner

okbob commented May 5, 2020 via email

@okbob
Copy link
Owner

okbob commented May 5, 2020

Thank you for pizza :)

@okbob okbob closed this as completed May 5, 2020
@tobwen
Copy link
Author

tobwen commented Apr 14, 2021

Interesting, it stopped working after an upgrade. psql (PostgreSQL) 12.6 just displays plain, comma-separated CSV data (including the ignored columns).

\setenv PAGER 'pspg -bXI --less-status-bar --csv --csv-header on --skip-columns-like=geom'
\pset format csv
select ...

Did something change in pspg or psql?

My pspg version:

# pspg --version
pspg-4.5.0
with readline (version: 0x0700)
with integrated menu
ncurses version: 6.1, patch: 20181013
ncurses with wide char support
ncurses widechar num: 1
wchar_t width: 4, max: 2147483647
with postgres client integration
with inotify support

@okbob
Copy link
Owner

okbob commented Apr 15, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants