From 09d5461d0185c2619b348855b067e5ba0971ad95 Mon Sep 17 00:00:00 2001 From: eelke Date: Sat, 5 Oct 2019 08:55:02 +0200 Subject: [PATCH 1/3] Seperate event types in the trigger definition with OR --- pglablib/catalog/PgTrigger.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pglablib/catalog/PgTrigger.cpp b/pglablib/catalog/PgTrigger.cpp index ba1ef9c..920a612 100644 --- a/pglablib/catalog/PgTrigger.cpp +++ b/pglablib/catalog/PgTrigger.cpp @@ -91,12 +91,18 @@ QString PgTrigger::event() const QString event; if (type & TriggerTypeInsert) event += "INSERT "; - if (type & TriggerTypeUpdate) + if (type & TriggerTypeUpdate) { + if (!event.isEmpty()) event += "OR "; event += "UPDATE "; - if (type & TriggerTypeDelete) + } + if (type & TriggerTypeDelete) { + if (!event.isEmpty()) event += "OR "; event += "DELETE "; - if (type & TriggerTypeTruncate) + } + if (type & TriggerTypeTruncate) { + if (!event.isEmpty()) event += "OR "; event += "TRUNCATE"; + } return event.trimmed(); } From e55b0b7f376d0f89ed1410ce637d9e6903688e06 Mon Sep 17 00:00:00 2001 From: eelke Date: Sat, 5 Oct 2019 09:09:22 +0200 Subject: [PATCH 2/3] fix: update sql for indexes and constraints When another table is selected the index and constraint list are reloaded and have no selection. So the SQL for the selection should be empty. --- pglab/widgets/CatalogConstraintPage.cpp | 1 + pglab/widgets/CatalogIndexPage.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/pglab/widgets/CatalogConstraintPage.cpp b/pglab/widgets/CatalogConstraintPage.cpp index 26d12a9..752be3a 100644 --- a/pglab/widgets/CatalogConstraintPage.cpp +++ b/pglab/widgets/CatalogConstraintPage.cpp @@ -26,6 +26,7 @@ void CatalogConstraintPage::setFilter(const std::optional &cls) { m_constraintModel->setData(m_catalog, cls); m_tableView->resizeColumnsToContents(); + m_definitionView->setPlainText({}); } void CatalogConstraintPage::tableView_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/) diff --git a/pglab/widgets/CatalogIndexPage.cpp b/pglab/widgets/CatalogIndexPage.cpp index 99bc789..25cafec 100644 --- a/pglab/widgets/CatalogIndexPage.cpp +++ b/pglab/widgets/CatalogIndexPage.cpp @@ -26,6 +26,7 @@ void CatalogIndexPage::setFilter(const std::optional &cls) { m_indexModel->setData(m_catalog, cls); m_tableView->resizeColumnsToContents(); + m_definitionView->setPlainText({}); } void CatalogIndexPage::tableView_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/) From 45c3a0480b157140233ba6eb9f320449b0d83723 Mon Sep 17 00:00:00 2001 From: eelke Date: Sat, 5 Oct 2019 16:41:14 +0200 Subject: [PATCH 3/3] The normal copy now works for SQL definition views. --- pglab/DatabaseWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pglab/DatabaseWindow.cpp b/pglab/DatabaseWindow.cpp index 4467836..fd14080 100644 --- a/pglab/DatabaseWindow.cpp +++ b/pglab/DatabaseWindow.cpp @@ -389,7 +389,7 @@ void DatabaseWindow::on_actionCopy_triggered() } else { const QMetaObject *meta = w->metaObject(); - int i = meta->indexOfSlot("copy"); + int i = meta->indexOfMethod("copy()"); if (i != -1) { QMetaMethod method = meta->method(i); method.invoke(w, Qt::AutoConnection);