add "PK FK" constraint to sql_table

This commit is contained in:
satoqz 2023-04-25 16:25:28 +02:00
parent acba0733db
commit dc14418ace
No known key found for this signature in database
2 changed files with 7 additions and 2 deletions

View file

@ -1024,8 +1024,11 @@ func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.R
}
maxTypeWidth = go2.Max(maxTypeWidth, typeDims.Width)
if c.Constraint != "" {
// covers UNQ constraint with padding
if c.Constraint == "primary_key_foreign_key" {
// covers "PK FK" constraint with padding
constraintWidth = 80
} else if c.Constraint != "" && constraintWidth == 0 {
// covers remaining constraints with "UNQ" being the largest
constraintWidth = 60
}
}

View file

@ -46,6 +46,8 @@ func (c SQLColumn) ConstraintAbbr() string {
return "PK"
case "foreign_key":
return "FK"
case "primary_key_foreign_key":
return "PK FK"
case "unique":
return "UNQ"
default: