Skip to content

Commit

Permalink
[DbManager] fetch type of view (materialized or not) and show in info
Browse files Browse the repository at this point in the history
(refs #13829)
  • Loading branch information
SebDieBln authored and brushtyler committed Jan 26, 2016
1 parent e42819d commit 5087811
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions python/plugins/db_manager/db_plugins/postgis/connector.py
Expand Up @@ -311,7 +311,7 @@ def getTables(self, schema=None, add_sys_tables=False):

# get all tables and views
sql = u"""SELECT
cla.relname, nsp.nspname, cla.relkind = 'v' OR cla.relkind = 'm',
cla.relname, nsp.nspname, cla.relkind,
pg_get_userbyid(relowner), reltuples, relpages,
pg_catalog.obj_description(cla.oid)
FROM pg_class AS cla
Expand Down Expand Up @@ -367,7 +367,7 @@ def getVectorTables(self, schema=None):

# discovery of all tables and whether they contain a geometry column
sql = u"""SELECT
cla.relname, nsp.nspname, cla.relkind = 'v' OR cla.relkind = 'm',
cla.relname, nsp.nspname, cla.relkind,
pg_get_userbyid(relowner), cla.reltuples, cla.relpages,
pg_catalog.obj_description(cla.oid),
""" + geometry_fields_select + """
Expand Down Expand Up @@ -439,7 +439,7 @@ def getRasterTables(self, schema=None):

# discovery of all tables and whether they contain a raster column
sql = u"""SELECT
cla.relname, nsp.nspname, cla.relkind = 'v' OR cla.relkind = 'm',
cla.relname, nsp.nspname, cla.relkind,
pg_get_userbyid(relowner), cla.reltuples, cla.relpages,
pg_catalog.obj_description(cla.oid),
""" + raster_fields_select + """
Expand Down
5 changes: 3 additions & 2 deletions python/plugins/db_manager/db_plugins/postgis/info_model.py
Expand Up @@ -44,8 +44,9 @@ def generalInfo(self):

tbl = [
(QApplication.translate("DBManagerPlugin", "Relation type:"),
QApplication.translate("DBManagerPlugin", "View") if self.table.isView else QApplication.translate(
"DBManagerPlugin", "Table")),
QApplication.translate("DBManagerPlugin", "View") if self.table._relationType == 'v' else
QApplication.translate("DBManagerPlugin", "Materialized view") if self.table._relationType == 'm' else
QApplication.translate("DBManagerPlugin", "Table")),
(QApplication.translate("DBManagerPlugin", "Owner:"), self.table.owner)
]
if self.table.comment:
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/db_manager/db_plugins/postgis/plugin.py
Expand Up @@ -160,7 +160,8 @@ class PGTable(Table):

def __init__(self, row, db, schema=None):
Table.__init__(self, db, schema)
self.name, schema_name, self.isView, self.owner, self.estimatedRowCount, self.pages, self.comment = row
self.name, schema_name, self._relationType, self.owner, self.estimatedRowCount, self.pages, self.comment = row
self.isView = self._relationType in set(['v', 'm'])
self.estimatedRowCount = int(self.estimatedRowCount)

def runVacuumAnalyze(self):
Expand Down

0 comments on commit 5087811

Please sign in to comment.