Generate COMMENT IS statements for columns
This commit is contained in:
parent
5777a9c834
commit
45795333f2
3 changed files with 16 additions and 3 deletions
|
|
@ -73,11 +73,16 @@ void ColumnPage::tableView_selectionChanged(const QItemSelection &/*selected*/,
|
|||
drops += ";";
|
||||
addsql += ";";
|
||||
m_definitionView->setPlainText(drops % "\n\n" % addsql);
|
||||
completeSql += drops % "\n\n" % addsql;
|
||||
completeSql += drops % "\n\n" % addsql % "\n\n";
|
||||
}
|
||||
else {
|
||||
m_definitionView->setPlainText("");
|
||||
for (auto r : rijen) {
|
||||
auto && col = m_columnModel->column(r);
|
||||
auto cs = col.commentStatement(*m_catalog, m_Class.value());
|
||||
if (!cs.isEmpty()) {
|
||||
completeSql += cs % "\n";
|
||||
}
|
||||
}
|
||||
|
||||
completeSql += "\n-- SQL to correct just the defaults\n";
|
||||
for (auto r : rijen) {
|
||||
auto && col = m_columnModel->column(r);
|
||||
|
|
|
|||
|
|
@ -63,4 +63,11 @@ QString PgAttribute::alterTableDropColumn(const PgDatabaseCatalog &cat, const Pg
|
|||
return sql;
|
||||
}
|
||||
|
||||
QString PgAttribute::commentStatement(const PgDatabaseCatalog &cat, const PgClass &table) const
|
||||
{
|
||||
if (description.isEmpty())
|
||||
return {};
|
||||
|
||||
return "COMMENT ON COLUMN " % table.fullyQualifiedQuotedObjectName() % "."
|
||||
% quoteIdent(name) % " IS " % escapeLiteral(description) % ";";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public:
|
|||
QString columnDefinition(const PgDatabaseCatalog &cat) const;
|
||||
QString alterTableAddColumn(const PgDatabaseCatalog &cat, const PgClass &table) const;
|
||||
QString alterTableDropColumn(const PgDatabaseCatalog &cat, const PgClass &table) const;
|
||||
QString commentStatement(const PgDatabaseCatalog &cat, const PgClass &table) const;
|
||||
|
||||
bool isSerial() const { return !sername.isEmpty(); }
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue