update sql texts measure

This commit is contained in:
Alexander Wang 2022-12-23 00:29:03 -08:00
parent 08c8a09364
commit 227afc45db
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
2 changed files with 19 additions and 14 deletions

View file

@ -1084,7 +1084,9 @@ func (g *Graph) Texts() []*d2target.MText {
}
} else if obj.SQLTable != nil {
for _, column := range obj.SQLTable.Columns {
texts = appendTextDedup(texts, column.Text())
for _, t := range column.Texts() {
texts = appendTextDedup(texts, t)
}
}
}
}

View file

@ -1,11 +1,5 @@
package d2target
import (
"fmt"
"oss.terrastruct.com/d2/d2renderers/d2fonts"
)
const (
NamePadding = 10
TypePadding = 20
@ -22,13 +16,22 @@ type SQLColumn struct {
Reference string `json:"reference"`
}
func (c SQLColumn) Text() *MText {
return &MText{
Text: fmt.Sprintf("%s%s%s%s", c.Name.Label, c.Type.Label, c.Constraint, c.Reference),
FontSize: d2fonts.FONT_SIZE_L,
IsBold: false,
IsItalic: false,
Shape: "sql_table",
func (c SQLColumn) Texts() []*MText {
return []*MText{
{
Text: c.Name.Label,
FontSize: c.Name.FontSize,
IsBold: false,
IsItalic: false,
Shape: "sql_table",
},
{
Text: c.Type.Label,
FontSize: c.Type.FontSize,
IsBold: false,
IsItalic: false,
Shape: "sql_table",
},
}
}