In the column list show foreign key constraint
This commit is contained in:
parent
8836611b62
commit
634345b38f
5 changed files with 65 additions and 12 deletions
|
|
@ -52,16 +52,17 @@ PgConstraint PgConstraintContainer::loadElem(const Pgsql::Row &row)
|
|||
return v;
|
||||
}
|
||||
|
||||
const PgConstraint* PgConstraintContainer::getFKeyForTableColumn(Oid relid, int16_t attnum) const
|
||||
std::vector<PgConstraint> PgConstraintContainer::getFKeyForTableColumn(Oid relid, int16_t attnum) const
|
||||
{
|
||||
const PgConstraint *result = nullptr;
|
||||
//const PgConstraint *result = nullptr;
|
||||
std::vector<PgConstraint> result;
|
||||
// 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());
|
||||
// });
|
||||
auto res = std::copy_if(m_container.begin(), m_container.end(), std::back_inserter(result),
|
||||
[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 c.type == ConstraintType::ForeignKey && relid == c.relid &&
|
||||
(std::find(c.key.begin(), c.key.end(), attnum) != c.key.end());
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue