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:
eelke 2017-12-19 18:57:05 +01:00
parent 8402470baa
commit a69aa401b2
3 changed files with 17 additions and 9 deletions

View file

@ -1,13 +1,19 @@
#include "PgAttributeContainer.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
{
return
"SELECT attrelid, attname, atttypid, attstattarget, \n"
" attnum, attndims, atttypmod, attnotnull, atthasdef, \n"
" attcollation, attacl, attoptions \n"
" FROM pg_catalog.pg_attribute";
return R"__(
SELECT attrelid, attname, atttypid, attstattarget,
attnum, attndims, atttypmod, attnotnull, atthasdef,
attcollation, attacl, attoptions, pg_get_expr(adbin, adrelid) AS def_value
FROM pg_catalog.pg_attribute
LEFT JOIN pg_attrdef ON attrelid=adrelid AND attnum=adnum)__";
}
PgAttribute PgAttributeContainer::loadElem(const Pgsql::Row &row)
@ -16,7 +22,7 @@ PgAttribute PgAttributeContainer::loadElem(const Pgsql::Row &row)
PgAttribute v;
col >> v.relid >> v.name >> v.typid >> v.stattarget
>> 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;
}