Skip to content

Commit 63c010d

Browse files
committed
Fix create and delete comment from tableProperties
1 parent f3dfd97 commit 63c010d

File tree

7 files changed

+38
-8
lines changed

7 files changed

+38
-8
lines changed

python/plugins/db_manager/db_plugins/gpkg/connector.py

+6
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,12 @@ def commentTable(self, schema, tablename, comment):
624624
"""Comment the table"""
625625
return ''
626626

627+
def commentTable(self, schema, tablename, comment):
628+
return ''
629+
630+
def unCommentTable(self, schema, tablename):
631+
return ''
632+
627633
def getComment(self, tab, field, db):
628634
"""Returns the comment for a field"""
629635
return ''

python/plugins/db_manager/db_plugins/oracle/connector.py

+6
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,12 @@ def commentTable(self, schema, tablename, comment):
13111311
"""Comment the table"""
13121312
return ''
13131313

1314+
def commentTable(self, schema, tablename, comment):
1315+
return ''
1316+
1317+
def unCommentTable(self, schema, tablename):
1318+
return ''
1319+
13141320
def getComment(self, tab, field, db):
13151321
"""Returns the comment for a field"""
13161322
return ''

python/plugins/db_manager/db_plugins/postgis/connector.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,11 @@ def renameTable(self, table, new_table):
743743

744744
self._commit()
745745

746-
def commentTable(self, schema, tablename, comment):
747-
self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}\''.format(schema, tablename, comment))
746+
def commentTable(self, schema, tablename, comment, db):
747+
db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}\';'.format(schema, tablename, comment))
748+
749+
def unCommentTable(self, schema, tablename, db):
750+
db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS NULL;'.format(schema, tablename))
748751

749752
def getComment(self, tab, field, db):
750753
"""Returns the comment for a field"""
@@ -754,7 +757,6 @@ def getComment(self, tab, field, db):
754757
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)
755758
c = db.connector._execute(None, sql_cpt) # Execute Check query
756759
res = db.connector._fetchone(c)[0] # Store result
757-
print(tab, field, sql_cpt, sql)
758760
if res == 1:
759761
# When a comment exists
760762
c = db.connector._execute(None, sql) # Execute query

python/plugins/db_manager/db_plugins/spatialite/connector.py

+6
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,12 @@ def commentTable(self, schema, tablename, comment):
575575
"""Comment the table"""
576576
return ''
577577

578+
def commentTable(self, schema, tablename, comment):
579+
return ''
580+
581+
def unCommentTable(self, schema, tablename):
582+
return ''
583+
578584
def getComment(self, tab, field, db):
579585
"""Returns the comment for a field"""
580586
return ''

python/plugins/db_manager/db_plugins/vlayers/connector.py

+6
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,12 @@ def commentTable(self, schema, tablename, comment):
346346
"""Comment the table"""
347347
return ''
348348

349+
def commentTable(self, schema, tablename, comment):
350+
return ''
351+
352+
def unCommentTable(self, schema, tablename):
353+
return ''
354+
349355
def getComment(self, tab, field, db):
350356
"""Returns the comment for a field"""
351357
return ''

python/plugins/db_manager/dlg_import_vector.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,10 @@ def accept(self):
373373
self.db.connector.createSpatialIndex((schema, table), geom)
374374

375375
# add comment on table
376+
supportCom = self.db.supportsComment()
376377
if self.chkCom.isEnabled() and self.chkCom.isChecked() and supportCom == True:
377378
# using connector executing COMMENT ON TABLE query (with editCome.text() value)
378-
self.db.connector.commentTable(db, schema, table, self.editCom.text())
379+
self.db.connector.commentTable(schema, table, self.editCom.text(), self.db)
379380

380381
self.db.connection().reconnect()
381382
self.db.refresh()

python/plugins/db_manager/dlg_table_properties.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,10 @@ def deleteIndex(self):
338338
def createComment(self):
339339
"""Adds a comment to the selected table"""
340340
try:
341-
#Using the db connector, executing de SQL query Comment on table
342-
self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS E\'{2}\';'.format(self.table.schema().name, self.table.name, self.viewComment.text()))
341+
schem = self.table.schema().name
342+
tab = self.table.name
343+
com = self.viewComment.text()
344+
self.db.connector.commentTable(schem, tab, com, self.db)
343345
except DbError as e:
344346
DlgDbError.showError(e, self)
345347
return
@@ -350,8 +352,9 @@ def createComment(self):
350352
def deleteComment(self):
351353
"""Drops the comment on the selected table"""
352354
try:
353-
#Using the db connector, executing de SQL query Comment on table using the NULL definition
354-
self.db.connector._execute(None, 'COMMENT ON TABLE "{0}"."{1}" IS NULL;'.format(self.table.schema().name, self.table.name))
355+
schem = self.table.schema().name
356+
tab = self.table.name
357+
self.db.connector.unCommentTable(schem, tab, self.db)
355358
except DbError as e:
356359
DlgDbError.showError(e, self)
357360
return

0 commit comments

Comments
 (0)