Skip to content

Commit

Permalink
DB manager fix add comment while creating table
Browse files Browse the repository at this point in the history
Fixes #38394
  • Loading branch information
elpaso committed Sep 25, 2020
1 parent 04ae0ca commit eb3c78d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/plugins/db_manager/db_plugins/data_model.py
Expand Up @@ -301,7 +301,7 @@ def getObject(self, row):

fld.notNull = self.data(self.index(row, 2), Qt.CheckStateRole) == Qt.Unchecked
fld.primaryKey = self.data(self.index(row, 1), Qt.UserRole)
fld.comment = self.data(self.index(row, 4), Qt.UserRole)
fld.comment = self.data(self.index(row, 4))
return fld

def getFields(self):
Expand Down
7 changes: 7 additions & 0 deletions python/plugins/db_manager/db_plugins/plugin.py
Expand Up @@ -585,6 +585,13 @@ def createTable(self, table, fields, schema=None):

ret = self.connector.createTable((schema, table), field_defs, pk_name)
if ret is not False:
# Add comments if any, because definition does not include
# the comment
for f in fields:
if f.comment:
self.connector.updateTableColumn(
(schema, table), f.name, comment=f.comment
)
self.refresh()
return ret

Expand Down

0 comments on commit eb3c78d

Please sign in to comment.