feat: add \dS suffix for system objects (pg_catalog, information_schema)#160
feat: add \dS suffix for system objects (pg_catalog, information_schema)#160Pawansingh3889 wants to merge 2 commits intodbcli:mainfrom
Conversation
Adds \dtS, \dvS, \dmS, \dsS, \diS, and \dS metacommands that include system objects from pg_catalog and information_schema, matching psql behavior. The existing \dt, \dv, etc. continue to exclude system objects. Implements this by adding a show_system parameter to list_objects(). When True, the pg_catalog/information_schema exclusion filter is skipped (pg_toast is still excluded). Closes dbcli/pgcli#1523
| elif show_system: | ||
| params["schema_pattern"] = SQL( | ||
| """ | ||
| AND n.nspname !~ '^pg_toast' """ |
There was a problem hiding this comment.
I thought the intent was to include both regular and system objects, right? Here, you're going to ignore user-provided pattern, and only show what matches your pattern. Tests would catch this, but the PR contains no tests.
There was a problem hiding this comment.
Ok, so the S modifier does this (from https://www.postgresql.org/docs/current/app-psql.html):
By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects.
The fallback condition on lines 490-493 excludes system objects:
AND n.nspname <> 'pg_catalog'
AND n.nspname <> 'information_schema'
AND n.nspname !~ '^pg_toast'
AND pg_catalog.pg_table_is_visible(c.oid)so in your elif show_system, you only want to keep this one:
AND pg_catalog.pg_table_is_visible(c.oid)There was a problem hiding this comment.
So my first comment was not accurate, I misread the condition. But the condition does not do what you want. And you still need tests.
Thanks!
Adds \dtS, \dvS, \dmS, \dsS, \diS, and \dS metacommands that include system objects from pg_catalog and information_schema, matching psql behavior.
Changes: