comments on columns
Show the comments in the list of columns of a table. Generate SQL to set them.
This commit is contained in:
parent
9d58af8cd2
commit
d6aeef492d
5 changed files with 23 additions and 3 deletions
|
|
@ -77,6 +77,9 @@ QVariant ColumnTableModel::headerData(int section, Qt::Orientation orientation,
|
|||
case CollationCol:
|
||||
c = tr("Collation");
|
||||
break;
|
||||
case CommentCol:
|
||||
c = tr("Comment");
|
||||
break;
|
||||
}
|
||||
}
|
||||
v = c;
|
||||
|
|
@ -200,6 +203,9 @@ QVariant ColumnTableModel::getData(const QModelIndex &index) const
|
|||
v = col->objectName();
|
||||
}
|
||||
break;
|
||||
case CommentCol:
|
||||
v = t.description;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public:
|
|||
DefaultCol,
|
||||
ForeignKeyCol,
|
||||
CollationCol,
|
||||
CommentCol,
|
||||
|
||||
colCount };
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "TablesTableModel.h"
|
||||
#include "TriggerPage.h"
|
||||
#include "SqlFormattingUtils.h"
|
||||
#include "catalog/PgAttributeContainer.h"
|
||||
#include "catalog/PgIndexContainer.h"
|
||||
#include "catalog/PgTriggerContainer.h"
|
||||
#include "widgets/CatalogConstraintPage.h"
|
||||
|
|
@ -218,6 +219,15 @@ void CatalogTablesPage::updateSqlTab(const std::optional<PgClass> &table)
|
|||
create_sql += "COMMENT ON TABLE " + table->fullyQualifiedQuotedObjectName()
|
||||
+ " IS " + dollarQuoteString(table->description) + ";\n";
|
||||
}
|
||||
|
||||
auto && cols = m_catalog->attributes()->getColumnsForRelation(table->oid());
|
||||
for (auto && col : cols) {
|
||||
if (!col.description.isEmpty()) {
|
||||
create_sql += "COMMENT ON COLUMN " + table->fullyQualifiedQuotedObjectName()
|
||||
+ "." + quoteIdent(col.name) + " IS " + dollarQuoteString(col.description) + ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
m_tableSql->setPlainText(drop_sql % "\n\n" % create_sql);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue