Make it recognize not null constraints and set type to Unknown when the value is not recognized.

Note column not null constraints where not stored in pg_constraint before postgresl 18
This commit is contained in:
eelke 2025-12-10 18:54:32 +01:00
parent cf7c0699fe
commit c1a5ac1aad
4 changed files with 24 additions and 2 deletions

View file

@ -525,7 +525,8 @@ void CrudModel::initializeColumnList()
{ {
columnList.clear(); columnList.clear();
columnList.reserve(m_roData->cols()); columnList.reserve(m_roData->cols());
auto columns = m_database->catalog()->attributes()->getColumnsForRelation(m_table->oid()); auto atts = m_database->catalog()->attributes();
auto columns = atts->getColumnsForRelation(m_table->oid());
for (int col = 0; col < m_roData->cols(); ++col) for (int col = 0; col < m_roData->cols(); ++col)
{ {
int attnum = m_roData->ftableCol(col); int attnum = m_roData->ftableCol(col);

View file

@ -211,6 +211,13 @@ private:
bool callLoadData = false; bool callLoadData = false;
std::shared_ptr<Pgsql::Result> m_roData; std::shared_ptr<Pgsql::Result> m_roData;
struct ColumnData
{
std::string name;
// identity allways or generated
};
std::vector<PgAttribute> columnList; // list of columnMeta 1 to 1 with columns in m_roData. std::vector<PgAttribute> columnList; // list of columnMeta 1 to 1 with columns in m_roData.
PendingRowList m_pendingRowList; PendingRowList m_pendingRowList;

View file

@ -24,6 +24,12 @@ void operator<<(ConstraintType &s, const Pgsql::Value &v)
case 'x': case 'x':
s = ConstraintType::ExclusionConstraint; s = ConstraintType::ExclusionConstraint;
break; break;
case 'n':
s = ConstraintType::NotNull;
break;
default:
s = ConstraintType::Unknown;
break;
} }
} }
@ -49,6 +55,9 @@ QString ShortNameForConstraintType(ConstraintType ct)
case ConstraintType::ExclusionConstraint: case ConstraintType::ExclusionConstraint:
s = "XC"; s = "XC";
break; break;
case ConstraintType::NotNull:
s = "NN";
break;
default: default:
s = "?"; s = "?";
break; break;
@ -78,6 +87,9 @@ QString LongNameForConstraintType(ConstraintType ct)
case ConstraintType::ExclusionConstraint: case ConstraintType::ExclusionConstraint:
s = "exclusion constraint"; s = "exclusion constraint";
break; break;
case ConstraintType::NotNull:
s = "not null";
break;
default: default:
s = "?"; s = "?";
break; break;

View file

@ -11,12 +11,14 @@
#include <vector> #include <vector>
enum class ConstraintType { enum class ConstraintType {
Unknown, // not recognized, new???
PrimaryKey, // p PrimaryKey, // p
ForeignKey, // f ForeignKey, // f
Unique, // u Unique, // u
Check, // c Check, // c
ConstraintTrigger, // t ConstraintTrigger, // t
ExclusionConstraint, // x ExclusionConstraint, // x
NotNull, // n
}; };
void operator<<(ConstraintType &s, const Pgsql::Value &v); void operator<<(ConstraintType &s, const Pgsql::Value &v);