diff options
-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): |