Added the trigger definitions to the sql for a table. Also tuned the formatting of the trigger definitions a bit.
This commit is contained in:
parent
4ec4e02411
commit
769307c821
2 changed files with 12 additions and 6 deletions
|
|
@ -3,13 +3,14 @@
|
|||
|
||||
#include "catalog/PgAttribute.h"
|
||||
#include "catalog/PgDatabaseCatalog.h"
|
||||
#include "catalog/PgIndexContainer.h"
|
||||
#include "catalog/PgTriggerContainer.h"
|
||||
#include "ColumnPage.h"
|
||||
#include "ColumnTableModel.h"
|
||||
#include "ConstraintModel.h"
|
||||
#include "IconColumnDelegate.h"
|
||||
#include "IndexModel.h"
|
||||
#include "MainWindow.h"
|
||||
#include "catalog/PgIndexContainer.h"
|
||||
#include "PgLabItemDelegate.h"
|
||||
#include "PropertiesPage.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
|
|
@ -264,10 +265,15 @@ void TablesPage::updateSqlTab(const std::optional<PgClass> &table)
|
|||
// 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";
|
||||
}
|
||||
|
||||
// Privileges
|
||||
create_sql += "-- set Privileges\n";
|
||||
create_sql += table->grantSql();
|
||||
create_sql += table->grantSql() % "\n";
|
||||
|
||||
// Comments
|
||||
create_sql += "-- set Comments table + columns\n";
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ QString PgTrigger::createSql()
|
|||
|
||||
m_createSql += "\n ON " + fqtablename;
|
||||
if (deferrable) {
|
||||
m_createSql += "\n DEFERRABLE INITIALLY ";
|
||||
m_createSql += " DEFERRABLE INITIALLY ";
|
||||
if (initdeferred)
|
||||
m_createSql += "DEFERRED";
|
||||
else
|
||||
|
|
@ -42,12 +42,12 @@ QString PgTrigger::createSql()
|
|||
|
||||
// requires atleast 8.5 don;t think we have to support older
|
||||
if (!whenclause.isEmpty())
|
||||
m_createSql += "\n WHEN (" + whenclause + ")";
|
||||
m_createSql += " WHEN (" + whenclause + ")";
|
||||
|
||||
m_createSql += QString("\n EXECUTE PROCEDURE %1;\n").arg(procedure());
|
||||
m_createSql += QString("\n EXECUTE PROCEDURE %1;").arg(procedure());
|
||||
|
||||
if (!enabled)
|
||||
m_createSql += QString("ALTER TABLE %1 DISABLE TRIGGER %2;\n").arg(fqtablename, triggername);
|
||||
m_createSql += QString("\nALTER TABLE %1 DISABLE TRIGGER %2;").arg(fqtablename, triggername);
|
||||
|
||||
// if (!GetComment().IsEmpty())
|
||||
// sql += wxT("COMMENT ON TRIGGER ") + GetQuotedIdentifier() + wxT(" ON ") + GetQuotedFullTable()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue