Skip to content

Commit

Permalink
[DbManager] allow to delete materialized views
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 9902613 commit 5600078
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions python/plugins/db_manager/db_plugins/postgis/connector.py
Expand Up @@ -794,8 +794,8 @@ def createView(self, view, query):
def createSpatialView(self, view, query):
self.createView(view, query)

def deleteView(self, view):
sql = u"DROP VIEW %s" % self.quoteId(view)
def deleteView(self, view, isMaterialized=False):
sql = u"DROP %s VIEW %s" % ('MATERIALIZED' if isMaterialized else '', self.quoteId(view))
self._execute_and_commit(sql)

def renameView(self, view, new_name):
Expand Down
12 changes: 11 additions & 1 deletion python/plugins/db_manager/db_plugins/postgis/plugin.py
Expand Up @@ -23,7 +23,7 @@
# this will disable the dbplugin if the connector raise an ImportError
from .connector import PostGisDBConnector

from PyQt4.QtCore import QSettings, Qt, QRegExp
from PyQt4.QtCore import QSettings, Qt, QRegExp, SIGNAL
from PyQt4.QtGui import QIcon, QAction, QApplication, QMessageBox
from qgis.gui import QgsMessageBar

Expand Down Expand Up @@ -227,6 +227,16 @@ def tableDataModel(self, parent):

return PGTableDataModel(self, parent)

def delete(self):
self.aboutToChange()
if self.isView:
ret = self.database().connector.deleteView((self.schemaName(), self.name), self._relationType == 'm')
else:
ret = self.database().connector.deleteTable((self.schemaName(), self.name))
if ret is not False:
self.emit(SIGNAL('deleted'))
return ret


class PGVectorTable(PGTable, VectorTable):

Expand Down

0 comments on commit 5600078

Please sign in to comment.