Show in constraint list and in generated SQL when a constraint is inherited
This commit is contained in:
parent
60fb4ce285
commit
ccd88d0578
5 changed files with 50 additions and 22 deletions
|
|
@ -34,13 +34,21 @@ void CatalogConstraintPage::setFilter(const std::optional<PgClass> &cls)
|
|||
|
||||
void CatalogConstraintPage::tableView_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
||||
{
|
||||
auto rijen = selectedRows();
|
||||
QString drops;
|
||||
QString creates;
|
||||
for (auto rij : rijen) {
|
||||
const PgConstraint constraint = m_constraintModel->constraint(rij);
|
||||
drops += constraint.dropSql() % "\n";
|
||||
creates += constraint.createSql() % "\n";
|
||||
}
|
||||
m_definitionView->setPlainText(drops % "\n" % creates);
|
||||
m_definitionView->setPlainText(
|
||||
generateSql(
|
||||
selectedRows()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
QString CatalogConstraintPage::generateSql(const std::unordered_set<int> &rijen)
|
||||
{
|
||||
QString drops;
|
||||
QString creates;
|
||||
for (auto rij : rijen) {
|
||||
const PgConstraint constraint = m_constraintModel->constraint(rij);
|
||||
drops += constraint.dropSql() % "\n";
|
||||
creates += constraint.createSql() % "\n";
|
||||
}
|
||||
return drops % "\n" % creates;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ private:
|
|||
|
||||
ConstraintModel *m_constraintModel = nullptr;
|
||||
|
||||
QString generateSql(const std::unordered_set<int> &rows);
|
||||
private slots:
|
||||
void tableView_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue