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
|
|
@ -126,7 +126,50 @@ QString getForeignKeyConstraintDefinition(const PgDatabaseCatalog &catalog, cons
|
|||
% " ON UPDATE " % ForeignKeyActionToString(constraint.fupdtype)
|
||||
% " ON DELETE " % ForeignKeyActionToString(constraint.fdeltype)
|
||||
% deferrable % validated % ";";
|
||||
}
|
||||
|
||||
QString getForeignKeyConstraintReferences(const PgDatabaseCatalog &catalog, const PgConstraint &constraint)
|
||||
{
|
||||
PgClass fcls = catalog.classes()->getByKey(constraint.frelid);
|
||||
QString deferrable;
|
||||
QString validated;
|
||||
if (!constraint.validated)
|
||||
validated += " NOT VALID";
|
||||
if (constraint.deferrable) {
|
||||
deferrable = QLatin1String(" DEFERRABLE INITIALLY ") % (constraint.deferred ? "DEFERRED" : "IMMEDIATE");
|
||||
}
|
||||
|
||||
return "REFERENCES "
|
||||
% genFQTableName(catalog, fcls) % " ("
|
||||
% getColumnNameList(catalog, constraint.frelid, constraint.fkey) % ") MATCH "
|
||||
% ForeignKeyMatchToString(constraint.fmatchtype)
|
||||
% " ON UPDATE " % ForeignKeyActionToString(constraint.fupdtype)
|
||||
% " ON DELETE " % ForeignKeyActionToString(constraint.fdeltype)
|
||||
% deferrable % validated;
|
||||
|
||||
}
|
||||
|
||||
|
||||
QString getForeignKeyConstraintReferencesShort(const PgDatabaseCatalog &catalog, const PgConstraint &constraint)
|
||||
{
|
||||
PgClass fcls = catalog.classes()->getByKey(constraint.frelid);
|
||||
QString deferrable;
|
||||
QString validated;
|
||||
if (!constraint.validated)
|
||||
validated += " NOT VALID";
|
||||
if (constraint.deferrable) {
|
||||
deferrable = QLatin1String(" DEFERRABLE") % (constraint.deferred ? " INITIALLY DEFERRED" : "");
|
||||
}
|
||||
QString on_update = constraint.fupdtype == ForeignKeyAction::NoAction ? QString() : " ON UPDATE " % ForeignKeyActionToString(constraint.fupdtype);
|
||||
QString on_delete = constraint.fdeltype == ForeignKeyAction::NoAction ? QString() : " ON DELETE " % ForeignKeyActionToString(constraint.fdeltype);
|
||||
QString match_type = constraint.fmatchtype == ForeignKeyMatch::Simple ? QString() : " MATCH " % ForeignKeyMatchToString(constraint.fmatchtype);
|
||||
|
||||
return genFQTableName(catalog, fcls) % " ("
|
||||
% getColumnNameList(catalog, constraint.frelid, constraint.fkey) % ")"
|
||||
% match_type
|
||||
% on_update
|
||||
% on_delete
|
||||
% deferrable % validated;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue