diff --git a/python/plugins/db_manager/db_plugins/gpkg/connector.py b/python/plugins/db_manager/db_plugins/gpkg/connector.py index 9fe63b57bd9..7b352912e30 100644 --- a/python/plugins/db_manager/db_plugins/gpkg/connector.py +++ b/python/plugins/db_manager/db_plugins/gpkg/connector.py @@ -624,6 +624,12 @@ class GPKGDBConnector(DBConnector): """Comment the table""" return '' + def commentTable(self, schema, tablename, comment): + return '' + + def unCommentTable(self, schema, tablename): + return '' + def getComment(self, tab, field, db): """Returns the comment for a field""" return '' diff --git a/python/plugins/db_manager/db_plugins/oracle/connector.py b/python/plugins/db_manager/db_plugins/oracle/connector.py index 83ada3b70b4..33897d5abf0 100644 --- a/python/plugins/db_manager/db_plugins/oracle/connector.py +++ b/python/plugins/db_manager/db_plugins/oracle/connector.py @@ -1311,6 +1311,12 @@ class OracleDBConnector(DBConnector): """Comment the table""" return '' + def commentTable(self, schema, tablename, comment): + return '' + + def unCommentTable(self, schema, tablename): + return '' + def getComment(self, tab, field, db): """Returns the comment for a field""" return '' diff --git a/python/plugins/db_manager/db_plugins/postgis/connector.py b/python/plugins/db_manager/db_plugins/postgis/connector.py index f40f4d4855b..ec20239a43c 100644 --- a/python/plugins/db_manager/db_plugins/postgis/connector.py +++ b/python/plugins/db_manager/db_plugins/postgis/connector.py @@ -743,8 +743,11 @@ class PostGisDBConnector(DBConnector): self._commit() - def commentTable(self, schema, tablename, comment): - self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}\''.format(schema, tablename, comment)) + def commentTable(self, schema, tablename, comment, db): + db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}\';'.format(schema, tablename, comment)) + + def unCommentTable(self, schema, tablename, db): + db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS NULL;'.format(schema, tablename)) def getComment(self, tab, field, db): """Returns the comment for a field""" @@ -754,7 +757,6 @@ class PostGisDBConnector(DBConnector): sql = "Select pd.description from pg_description pd, pg_class pc, pg_attribute pa where relname = '%s' and attname = '%s' and pa.attrelid = pc.oid and pd.objoid = pc.oid and pd.objsubid = pa.attnum" % (tab, field) c = db.connector._execute(None, sql_cpt) # Execute Check query res = db.connector._fetchone(c)[0] # Store result - print(tab, field, sql_cpt, sql) if res == 1: # When a comment exists c = db.connector._execute(None, sql) # Execute query diff --git a/python/plugins/db_manager/db_plugins/spatialite/connector.py b/python/plugins/db_manager/db_plugins/spatialite/connector.py index d6a148e5002..d444e0d8782 100644 --- a/python/plugins/db_manager/db_plugins/spatialite/connector.py +++ b/python/plugins/db_manager/db_plugins/spatialite/connector.py @@ -575,6 +575,12 @@ class SpatiaLiteDBConnector(DBConnector): """Comment the table""" return '' + def commentTable(self, schema, tablename, comment): + return '' + + def unCommentTable(self, schema, tablename): + return '' + def getComment(self, tab, field, db): """Returns the comment for a field""" return '' diff --git a/python/plugins/db_manager/db_plugins/vlayers/connector.py b/python/plugins/db_manager/db_plugins/vlayers/connector.py index 0d996a4bd23..d4cf8cce0ef 100644 --- a/python/plugins/db_manager/db_plugins/vlayers/connector.py +++ b/python/plugins/db_manager/db_plugins/vlayers/connector.py @@ -346,6 +346,12 @@ class VLayerConnector(DBConnector): """Comment the table""" return '' + def commentTable(self, schema, tablename, comment): + return '' + + def unCommentTable(self, schema, tablename): + return '' + def getComment(self, tab, field, db): """Returns the comment for a field""" return '' diff --git a/python/plugins/db_manager/dlg_import_vector.py b/python/plugins/db_manager/dlg_import_vector.py index 3ef50415c94..118eb77e74c 100644 --- a/python/plugins/db_manager/dlg_import_vector.py +++ b/python/plugins/db_manager/dlg_import_vector.py @@ -373,9 +373,10 @@ class DlgImportVector(QDialog, Ui_Dialog): self.db.connector.createSpatialIndex((schema, table), geom) # add comment on table + supportCom = self.db.supportsComment() if self.chkCom.isEnabled() and self.chkCom.isChecked() and supportCom == True: # using connector executing COMMENT ON TABLE query (with editCome.text() value) - self.db.connector.commentTable(db, schema, table, self.editCom.text()) + self.db.connector.commentTable(schema, table, self.editCom.text(), self.db) self.db.connection().reconnect() self.db.refresh() diff --git a/python/plugins/db_manager/dlg_table_properties.py b/python/plugins/db_manager/dlg_table_properties.py index 397b9916bee..d04fdd50009 100644 --- a/python/plugins/db_manager/dlg_table_properties.py +++ b/python/plugins/db_manager/dlg_table_properties.py @@ -338,8 +338,10 @@ class DlgTableProperties(QDialog, Ui_Dialog): def createComment(self): """Adds a comment to the selected table""" try: - #Using the db connector, executing de SQL query Comment on table - self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}\';'.format(self.table.schema().name, self.table.name, self.viewComment.text())) + schem = self.table.schema().name + tab = self.table.name + com = self.viewComment.text() + self.db.connector.commentTable(schem, tab, com, self.db) except DbError as e: DlgDbError.showError(e, self) return @@ -350,8 +352,9 @@ class DlgTableProperties(QDialog, Ui_Dialog): def deleteComment(self): """Drops the comment on the selected table""" try: - #Using the db connector, executing de SQL query Comment on table using the NULL definition - self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS NULL;'.format(self.table.schema().name, self.table.name)) + schem = self.table.schema().name + tab = self.table.name + self.db.connector.unCommentTable(schem, tab, self.db) except DbError as e: DlgDbError.showError(e, self) return