Skip to content
Permalink
Browse files

[DbManager] allow to delete materialized views

(refs #13829)
  • Loading branch information
SebDieBln authored and brushtyler committed Jan 26, 2016
1 parent 9902613 commit 560007846a4577767cf1f78d2e99a3a737be3331
@@ -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):
@@ -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

@@ -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):

0 comments on commit 5600078

Please sign in to comment.
You can’t perform that action at this time.