diff options
author | lazydba247 <nakache@gmail.com> | 2020-02-14 00:24:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-13 14:24:37 -0800 |
commit | 91263c37b94a1a3b45be13d35ff1ea19c7b8e1b7 (patch) | |
tree | 0a140541c0ad3e49b479c49299d81af00c2f88d4 | |
parent | 8fe316e5376738880c9cf4013f37ff357f428e19 (diff) |
Add Support for partitioned tables. (#1145)
* partitioned tables: add support
Starting from 9.6+ relkind has new members (more info here: https://www.postgresql.org/docs/12/catalog-pg-class.html)
* Update AUTHORS
* Update changelog.rst
* foreign tables: add support
Starting from 9.6+ relkind has new members (more info here: https://www.postgresql.org/docs/12/catalog-pg-class.html)
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | changelog.rst | 1 | ||||
-rw-r--r-- | pgcli/pgexecute.py | 12 |
3 files changed, 10 insertions, 4 deletions
@@ -104,6 +104,7 @@ Contributors: * Jonas Jelten * BrownShibaDog * George Thomas(thegeorgeous) + * Yoni Nakache(lazydba247) Creator: -------- diff --git a/changelog.rst b/changelog.rst index 68d8c1b6..1bc7d8c4 100644 --- a/changelog.rst +++ b/changelog.rst @@ -6,6 +6,7 @@ Features: * Add `__main__.py` file to execute pgcli as a package directly (#1123). * Add support for ANSI escape sequences for coloring the prompt (#1122). +* Add support for partitioned tables (relkind "p"). Bug fixes: diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index e4605c02..20ef5518 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -515,11 +515,13 @@ class PGExecute(object): cur.execute(self.schemata_query) return [x[0] for x in cur.fetchall()] - def _relations(self, kinds=("r", "v", "m")): + def _relations(self, kinds=("r", "p", "f", "v", "m")): """Get table or view name metadata :param kinds: list of postgres relkind filters: 'r' - table + 'p' - partitioned table + 'f' - foreign table 'v' - view 'm' - materialized view :return: (schema_name, rel_name) tuples @@ -534,7 +536,7 @@ class PGExecute(object): def tables(self): """Yields (schema_name, table_name) tuples""" - for row in self._relations(kinds=["r"]): + for row in self._relations(kinds=["r", "p", "f"]): yield row def views(self): @@ -545,11 +547,13 @@ class PGExecute(object): for row in self._relations(kinds=["v", "m"]): yield row - def _columns(self, kinds=("r", "v", "m")): + def _columns(self, kinds=("r", "p", "f", "v", "m")): """Get column metadata for tables and views :param kinds: kinds: list of postgres relkind filters: 'r' - table + 'p' - partitioned table + 'f' - foreign table 'v' - view 'm' - materialized view :return: list of (schema_name, relation_name, column_name, column_type) tuples @@ -603,7 +607,7 @@ class PGExecute(object): yield row def table_columns(self): - for row in self._columns(kinds=["r"]): + for row in self._columns(kinds=["r", "p", "f"]): yield row def view_columns(self): |