Skip to content
Permalink
Browse files

Fix create and delete comment from tableProperties

  • Loading branch information
Ailurupoda committed Feb 7, 2019
1 parent f3dfd97 commit 63c010dbb580b048e11df315f1a2043a27154ef9
@@ -624,6 +624,12 @@ def commentTable(self, schema, tablename, comment):
"""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 @@ def commentTable(self, schema, tablename, comment):
"""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 @@ def renameTable(self, table, new_table):

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 @@ def getComment(self, tab, field, db):
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 @@ def commentTable(self, schema, tablename, comment):
"""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 @@ def commentTable(self, schema, tablename, comment):
"""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 @@ def accept(self):
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 @@ def deleteIndex(self):
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 @@ def createComment(self):
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

0 comments on commit 63c010d

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