Show SQL for database
Also improvements to the SQL for tables and views.
This commit is contained in:
parent
b5a706a2a2
commit
3158a4364b
12 changed files with 172 additions and 58 deletions
|
|
@ -20,7 +20,7 @@
|
|||
#include <QApplication>
|
||||
#include <QHeaderView>
|
||||
#include <QStringBuilder>
|
||||
#include <QSortFilterProxyModel>
|
||||
//#include <QSortFilterProxyModel>
|
||||
#include <QTableWidget>
|
||||
|
||||
CatalogTablesPage::CatalogTablesPage(std::shared_ptr<OpenDatabase> opendatabase, QWidget *parent)
|
||||
|
|
@ -69,12 +69,6 @@ CatalogTablesPage::CatalogTablesPage(std::shared_ptr<OpenDatabase> opendatabase,
|
|||
// Signals
|
||||
connect(tv->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
|
||||
&CatalogTablesPage::tableListTable_currentRowChanged);
|
||||
// connect(m_tablesTableView.dataModel(), &TablesTableModel::modelReset,
|
||||
// [this] ()
|
||||
// {
|
||||
// selectedTableChanged({});
|
||||
// m_propertiesPage->setActiveRow({});
|
||||
// });
|
||||
|
||||
connect(m_tablesTableView.dataModel(), &QAbstractItemModel::layoutChanged,
|
||||
this, &CatalogTablesPage::tableListTable_layoutChanged);
|
||||
|
|
@ -117,10 +111,11 @@ void CatalogTablesPage::setNamespaceFilter(NamespaceFilter filter)
|
|||
|
||||
void CatalogTablesPage::tableListTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
{
|
||||
if (current.row() != previous.row()) {
|
||||
auto table = m_tablesTableView.rowItemForProxyIndex(current);
|
||||
selectedTableChanged(table);
|
||||
}
|
||||
if (current.row() == previous.row())
|
||||
return;
|
||||
|
||||
auto table = m_tablesTableView.rowItemForProxyIndex(current);
|
||||
selectedTableChanged(table);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -160,8 +155,9 @@ void CatalogTablesPage::updateSqlTab(const std::optional<PgClass> &table)
|
|||
|
||||
QString drop_sql;
|
||||
QString create_sql;
|
||||
// create table
|
||||
create_sql += table->createSql();
|
||||
// table
|
||||
drop_sql += table->dropSql() % "\n";
|
||||
create_sql += table->createSql() % "\n";
|
||||
// - columns
|
||||
// - constraints
|
||||
// table details (inherits etc)
|
||||
|
|
@ -194,10 +190,7 @@ 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";
|
||||
}
|
||||
create_sql += table->commentSql() % "\n";
|
||||
|
||||
auto && cols = m_catalog->attributes()->getColumnsForRelation(table->oid());
|
||||
for (auto && col : cols) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue