Rename From/To to Src/Dst

This commit is contained in:
Júlio César Batista 2022-11-16 15:54:34 -03:00
parent 505a4d38ce
commit 06a30f7820
No known key found for this signature in database
GPG key ID: 10C4B861BF314878
4 changed files with 20 additions and 20 deletions

View file

@ -681,11 +681,11 @@ func (c *compiler) compileSQLTable(obj *d2graph.Object) {
} }
if srcID == absID { if srcID == absID {
d2Col.Reference = strings.TrimPrefix(dstID, parentID+".") d2Col.Reference = strings.TrimPrefix(dstID, parentID+".")
e.FromTableColumnIndex = new(int) e.SrcTableColumnIndex = new(int)
*e.FromTableColumnIndex = len(obj.SQLTable.Columns) *e.SrcTableColumnIndex = len(obj.SQLTable.Columns)
} else if dstID == absID { } else if dstID == absID {
e.ToTableColumnIndex = new(int) e.DstTableColumnIndex = new(int)
*e.ToTableColumnIndex = len(obj.SQLTable.Columns) *e.DstTableColumnIndex = len(obj.SQLTable.Columns)
} }
} }
@ -746,13 +746,13 @@ func flattenContainer(g *d2graph.Graph, obj *d2graph.Object) {
newEdge, _ = g.Root.Connect(e.Src.AbsIDArray(), obj.AbsIDArray(), e.SrcArrow, e.DstArrow, e.Attributes.Label.Value) newEdge, _ = g.Root.Connect(e.Src.AbsIDArray(), obj.AbsIDArray(), e.SrcArrow, e.DstArrow, e.Attributes.Label.Value)
} }
// TODO more attributes // TODO more attributes
if e.FromTableColumnIndex != nil { if e.SrcTableColumnIndex != nil {
newEdge.FromTableColumnIndex = new(int) newEdge.SrcTableColumnIndex = new(int)
*newEdge.FromTableColumnIndex = *e.FromTableColumnIndex *newEdge.SrcTableColumnIndex = *e.SrcTableColumnIndex
} }
if e.ToTableColumnIndex != nil { if e.DstTableColumnIndex != nil {
newEdge.ToTableColumnIndex = new(int) newEdge.DstTableColumnIndex = new(int)
*newEdge.ToTableColumnIndex = *e.ToTableColumnIndex *newEdge.DstTableColumnIndex = *e.DstTableColumnIndex
} }
newEdge.Attributes.Label = e.Attributes.Label newEdge.Attributes.Label = e.Attributes.Label
newEdge.References = e.References newEdge.References = e.References

View file

@ -1491,13 +1491,13 @@ dst: {
dst.id <-> src.dst_id dst.id <-> src.dst_id
`, `,
assertions: func(t *testing.T, g *d2graph.Graph) { assertions: func(t *testing.T, g *d2graph.Graph) {
fromIndex := g.Edges[0].FromTableColumnIndex srcIndex := g.Edges[0].SrcTableColumnIndex
if fromIndex == nil || *fromIndex != 0 { if srcIndex == nil || *srcIndex != 0 {
t.Fatalf("Expected FromTableColumnIndex to be 0, got %v", fromIndex) t.Fatalf("Expected SrcTableColumnIndex to be 0, got %v", srcIndex)
} }
toIndex := g.Edges[0].ToTableColumnIndex dstIndex := g.Edges[0].DstTableColumnIndex
if toIndex == nil || *toIndex != 1 { if dstIndex == nil || *dstIndex != 1 {
t.Fatalf("Expected ToTableColumnIndex to be 1, got %v", toIndex) t.Fatalf("Expected DstTableColumnIndex to be 1, got %v", dstIndex)
} }
}, },
}, },

View file

@ -607,8 +607,8 @@ type Edge struct {
MinWidth int `json:"minWidth"` MinWidth int `json:"minWidth"`
MinHeight int `json:"minHeight"` MinHeight int `json:"minHeight"`
FromTableColumnIndex *int `json:"fromTableColumnIndex,omitempty"` SrcTableColumnIndex *int `json:"srcTableColumnIndex,omitempty"`
ToTableColumnIndex *int `json:"toTableColumnIndex,omitempty"` DstTableColumnIndex *int `json:"dstTableColumnIndex,omitempty"`
LabelDimensions d2target.TextDimensions `json:"label_dimensions"` LabelDimensions d2target.TextDimensions `json:"label_dimensions"`
LabelPosition *string `json:"labelPosition,omitempty"` LabelPosition *string `json:"labelPosition,omitempty"`

View file

@ -352,8 +352,8 @@
"index": 0, "index": 0,
"minWidth": 0, "minWidth": 0,
"minHeight": 0, "minHeight": 0,
"fromTableColumnIndex": 0, "srcTableColumnIndex": 0,
"toTableColumnIndex": 1, "dstTableColumnIndex": 1,
"label_dimensions": { "label_dimensions": {
"width": 0, "width": 0,
"height": 0 "height": 0