Skip to content

Commit 5087811

Browse files
SebDieBlnbrushtyler
authored andcommitted
[DbManager] fetch type of view (materialized or not) and show in info
(refs #13829)
1 parent e42819d commit 5087811

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

python/plugins/db_manager/db_plugins/postgis/connector.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def getTables(self, schema=None, add_sys_tables=False):
311311

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

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

440440
# discovery of all tables and whether they contain a raster column
441441
sql = u"""SELECT
442-
cla.relname, nsp.nspname, cla.relkind = 'v' OR cla.relkind = 'm',
442+
cla.relname, nsp.nspname, cla.relkind,
443443
pg_get_userbyid(relowner), cla.reltuples, cla.relpages,
444444
pg_catalog.obj_description(cla.oid),
445445
""" + raster_fields_select + """

python/plugins/db_manager/db_plugins/postgis/info_model.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ def generalInfo(self):
4444

4545
tbl = [
4646
(QApplication.translate("DBManagerPlugin", "Relation type:"),
47-
QApplication.translate("DBManagerPlugin", "View") if self.table.isView else QApplication.translate(
48-
"DBManagerPlugin", "Table")),
47+
QApplication.translate("DBManagerPlugin", "View") if self.table._relationType == 'v' else
48+
QApplication.translate("DBManagerPlugin", "Materialized view") if self.table._relationType == 'm' else
49+
QApplication.translate("DBManagerPlugin", "Table")),
4950
(QApplication.translate("DBManagerPlugin", "Owner:"), self.table.owner)
5051
]
5152
if self.table.comment:

python/plugins/db_manager/db_plugins/postgis/plugin.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ class PGTable(Table):
160160

161161
def __init__(self, row, db, schema=None):
162162
Table.__init__(self, db, schema)
163-
self.name, schema_name, self.isView, self.owner, self.estimatedRowCount, self.pages, self.comment = row
163+
self.name, schema_name, self._relationType, self.owner, self.estimatedRowCount, self.pages, self.comment = row
164+
self.isView = self._relationType in set(['v', 'm'])
164165
self.estimatedRowCount = int(self.estimatedRowCount)
165166

166167
def runVacuumAnalyze(self):

0 commit comments

Comments
 (0)