Th default values of columns are now joined with the other column data and displayed in the default column of the column tableview.
This commit is contained in:
parent
8402470baa
commit
a69aa401b2
3 changed files with 17 additions and 9 deletions
|
|
@ -63,7 +63,7 @@ QVariant ColumnTableModel::headerData(int section, Qt::Orientation orientation,
|
||||||
c = tr("Type");
|
c = tr("Type");
|
||||||
break;
|
break;
|
||||||
case NullCol:
|
case NullCol:
|
||||||
c = tr("Nullable");
|
c = tr("Not null");
|
||||||
break;
|
break;
|
||||||
case DefaultCol:
|
case DefaultCol:
|
||||||
c = tr("Default");
|
c = tr("Default");
|
||||||
|
|
@ -136,10 +136,10 @@ QVariant ColumnTableModel::getData(const QModelIndex &index) const
|
||||||
s = getTypeDisplayString(*m_catalog, t.typid);
|
s = getTypeDisplayString(*m_catalog, t.typid);
|
||||||
break;
|
break;
|
||||||
case NullCol:
|
case NullCol:
|
||||||
s = t.notnull ? "NOT NULL" : "";
|
s = QString::fromStdU16String(t.notnull ? u"\u2713" : u"");
|
||||||
break;
|
break;
|
||||||
case DefaultCol:
|
case DefaultCol:
|
||||||
s = "";
|
s = t.defaultValue;
|
||||||
break;
|
break;
|
||||||
case CollationCol:
|
case CollationCol:
|
||||||
s = ""; //t.collation;
|
s = ""; //t.collation;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ public:
|
||||||
QString acl;
|
QString acl;
|
||||||
QString options;
|
QString options;
|
||||||
|
|
||||||
|
QString defaultValue; ///< Comes from pg_attrdef table
|
||||||
|
|
||||||
|
|
||||||
bool operator==(Key _k) const { return relid == std::get<0>(_k) && num == std::get<1>(_k); }
|
bool operator==(Key _k) const { return relid == std::get<0>(_k) && num == std::get<1>(_k); }
|
||||||
bool operator==(const QString &n) const { return name == n; }
|
bool operator==(const QString &n) const { return name == n; }
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,19 @@
|
||||||
#include "PgAttributeContainer.h"
|
#include "PgAttributeContainer.h"
|
||||||
#include "Pgsql_Col.h"
|
#include "Pgsql_Col.h"
|
||||||
|
|
||||||
|
//SELECT attname, pg_get_expr(adbin, adrelid) AS def_value
|
||||||
|
//FROM pg_attribute
|
||||||
|
// JOIN pg_attrdef ON attrelid=adrelid AND attnum=adnum
|
||||||
|
//WHERE atthasdef=true
|
||||||
|
|
||||||
std::string PgAttributeContainer::getLoadQuery() const
|
std::string PgAttributeContainer::getLoadQuery() const
|
||||||
{
|
{
|
||||||
return
|
return R"__(
|
||||||
"SELECT attrelid, attname, atttypid, attstattarget, \n"
|
SELECT attrelid, attname, atttypid, attstattarget,
|
||||||
" attnum, attndims, atttypmod, attnotnull, atthasdef, \n"
|
attnum, attndims, atttypmod, attnotnull, atthasdef,
|
||||||
" attcollation, attacl, attoptions \n"
|
attcollation, attacl, attoptions, pg_get_expr(adbin, adrelid) AS def_value
|
||||||
" FROM pg_catalog.pg_attribute";
|
FROM pg_catalog.pg_attribute
|
||||||
|
LEFT JOIN pg_attrdef ON attrelid=adrelid AND attnum=adnum)__";
|
||||||
}
|
}
|
||||||
|
|
||||||
PgAttribute PgAttributeContainer::loadElem(const Pgsql::Row &row)
|
PgAttribute PgAttributeContainer::loadElem(const Pgsql::Row &row)
|
||||||
|
|
@ -16,7 +22,7 @@ PgAttribute PgAttributeContainer::loadElem(const Pgsql::Row &row)
|
||||||
PgAttribute v;
|
PgAttribute v;
|
||||||
col >> v.relid >> v.name >> v.typid >> v.stattarget
|
col >> v.relid >> v.name >> v.typid >> v.stattarget
|
||||||
>> v.num >> v.ndims >> v.typmod >> v.notnull >> v.hasdef
|
>> v.num >> v.ndims >> v.typmod >> v.notnull >> v.hasdef
|
||||||
>> v.collation >> v.acl >> v.options;
|
>> v.collation >> v.acl >> v.options >> v.defaultValue;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue