comments on tables
Show them in the list of tables. Genereate SQL to set the comment.
This commit is contained in:
parent
7fbc828326
commit
9d58af8cd2
5 changed files with 34 additions and 18 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#include "SqlCodePreview.h"
|
||||
#include "TablesTableModel.h"
|
||||
#include "TriggerPage.h"
|
||||
#include "SqlFormattingUtils.h"
|
||||
#include "catalog/PgIndexContainer.h"
|
||||
#include "catalog/PgTriggerContainer.h"
|
||||
#include "widgets/CatalogConstraintPage.h"
|
||||
|
|
@ -186,22 +187,26 @@ void CatalogTablesPage::updateSqlTab(const std::optional<PgClass> &table)
|
|||
// table details (inherits etc)
|
||||
|
||||
// Indexes
|
||||
drop_sql += "-- drop Indexes\n";
|
||||
create_sql += "-- create Indexes\n";
|
||||
auto && indexes = m_catalog->indexes()->getIndexesForTable(table->oid());
|
||||
for (auto && index : indexes) {
|
||||
drop_sql += index.dropSql() % "\n";
|
||||
create_sql += index.createSql() % "\n";
|
||||
}
|
||||
if (!indexes.empty()) {
|
||||
drop_sql += "-- drop Indexes\n";
|
||||
create_sql += "-- create Indexes\n";
|
||||
for (auto && index : indexes) {
|
||||
drop_sql += index.dropSql() % "\n";
|
||||
create_sql += index.createSql() % "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Triggers
|
||||
drop_sql += "-- drop Triggers\n";
|
||||
create_sql += "-- create Triggers\n";
|
||||
auto && triggers = m_catalog->triggers()->getTriggersForRelation(table->oid());
|
||||
for (auto && trg : triggers) {
|
||||
drop_sql += trg.dropSql() % "\n";
|
||||
create_sql += trg.createSql() % "\n";
|
||||
}
|
||||
auto && triggers = m_catalog->triggers()->getTriggersForRelation(table->oid());
|
||||
if (!triggers.empty()) {
|
||||
drop_sql += "-- drop Triggers\n";
|
||||
create_sql += "-- create Triggers\n";
|
||||
for (auto && trg : triggers) {
|
||||
drop_sql += trg.dropSql() % "\n";
|
||||
create_sql += trg.createSql() % "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Privileges
|
||||
create_sql += "-- set Privileges\n";
|
||||
|
|
@ -209,6 +214,10 @@ void CatalogTablesPage::updateSqlTab(const std::optional<PgClass> &table)
|
|||
|
||||
// Comments
|
||||
create_sql += "-- set Comments table + columns\n";
|
||||
//
|
||||
if (!table->description.isEmpty()) {
|
||||
create_sql += "COMMENT ON TABLE " + table->fullyQualifiedQuotedObjectName()
|
||||
+ " IS " + dollarQuoteString(table->description) + ";\n";
|
||||
}
|
||||
//
|
||||
m_tableSql->setPlainText(drop_sql % "\n\n" % create_sql);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue