mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-12 00:06:43 -04:00
Fix create and delete comment from tableProperties
This commit is contained in:
parent
f3dfd97d90
commit
63c010dbb5
@ -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 ''
|
||||
|
@ -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 ''
|
||||
|
@ -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
|
||||
|
@ -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 ''
|
||||
|
@ -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 ''
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user