The oid column is now shown for tables that are "with oids".
This commit is contained in:
parent
172e2bcd1d
commit
7051ef2efc
5 changed files with 23 additions and 9 deletions
|
|
@ -8,24 +8,29 @@
|
|||
#include "ScopeGuard.h"
|
||||
#include <QBrush>
|
||||
|
||||
void ColumnTableModel::setData(std::shared_ptr<const PgDatabaseCatalog> cat, Oid table_oid)
|
||||
void ColumnTableModel::setData(std::shared_ptr<const PgDatabaseCatalog> cat, const PgClass &table)
|
||||
{
|
||||
beginResetModel();
|
||||
SCOPE_EXIT { endResetModel(); };
|
||||
|
||||
m_table = table;
|
||||
m_catalog = cat;
|
||||
m_columns = cat->attributes()->getColumnsForRelation(table_oid);
|
||||
m_columns = cat->attributes()->getColumnsForRelation(table.oid);
|
||||
|
||||
// hide system columns
|
||||
m_columns.erase(std::remove_if(m_columns.begin(), m_columns.end(),
|
||||
[](auto &e) { return e.num <= 0; } ),
|
||||
m_columns.end());
|
||||
auto si = table.hasoids
|
||||
? std::remove_if(m_columns.begin(), m_columns.end(),
|
||||
[](PgAttribute &e) { return e.num <= 0 && e.name != "oid"; })
|
||||
: std::remove_if(m_columns.begin(), m_columns.end(),
|
||||
[](PgAttribute &e) { return e.num <= 0; });
|
||||
// move columns to end and remove them
|
||||
m_columns.erase(si, m_columns.end());
|
||||
|
||||
// sort remaining columns by order in table
|
||||
std::sort(m_columns.begin(), m_columns.end(),
|
||||
[] (auto &l, auto &r) -> bool { return l.num < r.num; });
|
||||
|
||||
m_indexes = m_catalog->indexes()->getIndexesForTable(table_oid);
|
||||
m_indexes = m_catalog->indexes()->getIndexesForTable(table.oid);
|
||||
std::sort(m_indexes.begin(), m_indexes.end(),
|
||||
[] (const auto &l, const auto &r) -> bool
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue