Made a start with showing foreignkeys in column list.

Not finished, need to decide what to do with multiple and multi column fkeys.
This commit is contained in:
eelke 2017-12-25 10:31:58 +01:00
parent a76686acfd
commit 190a6c04dc
14 changed files with 97 additions and 94 deletions

View file

@ -1,5 +1,6 @@
#include "PgConstraintContainer.h"
#include "Pgsql_Col.h"
#include <algorithm>
std::string PgConstraintContainer::getLoadQuery() const
{
@ -30,6 +31,8 @@ FROM pg_constraint)__";
//}
PgConstraint PgConstraintContainer::loadElem(const Pgsql::Row &row)
{
Pgsql::Col col(row);
@ -47,3 +50,16 @@ PgConstraint PgConstraintContainer::loadElem(const Pgsql::Row &row)
col >> v.bin >> v.src >> v.definition;
return v;
}
const PgConstraint* PgConstraintContainer::getFKeyForTableColumn(Oid relid, int16_t attnum) const
{
const PgConstraint *result = nullptr;
// WHat do we want to find here? On ly single column constraints or all contstraints.
// auto res = std::find_if(m_container.begin(), m_container.end(),
// [relid, attnum] (const auto &c) {
// // the find on v.key may not look super efficient but remember it in general only has one or two elements.
// return relid == c.relid &&
// (std::find(attnum.begin(), attnum.end(), v.key) != attnum.end());
// });
return result;
}