Rename rows to columns and omit empty indices
This commit is contained in:
parent
a943bea111
commit
07bd4cca50
3 changed files with 49 additions and 8 deletions
|
|
@ -680,11 +680,12 @@ func (c *compiler) compileSQLTable(obj *d2graph.Object) {
|
|||
continue
|
||||
}
|
||||
if srcID == absID {
|
||||
// Frontend isn't aware of container IDs.
|
||||
d2Col.Reference = strings.TrimPrefix(dstID, parentID+".")
|
||||
e.FromTableRowIndex = len(obj.SQLTable.Columns)
|
||||
} else {
|
||||
e.ToTableRowIndex = len(obj.SQLTable.Columns)
|
||||
e.FromTableColumnIndex = new(int)
|
||||
*e.FromTableColumnIndex = len(obj.SQLTable.Columns)
|
||||
} else if dstID == absID {
|
||||
e.ToTableColumnIndex = new(int)
|
||||
*e.ToTableColumnIndex = len(obj.SQLTable.Columns)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -745,8 +746,10 @@ 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)
|
||||
}
|
||||
// TODO more attributes
|
||||
newEdge.FromTableRowIndex = e.FromTableRowIndex
|
||||
newEdge.ToTableRowIndex = e.ToTableRowIndex
|
||||
newEdge.FromTableColumnIndex = new(int)
|
||||
*newEdge.FromTableColumnIndex = *e.FromTableColumnIndex
|
||||
newEdge.ToTableColumnIndex = new(int)
|
||||
*newEdge.ToTableColumnIndex = *e.ToTableColumnIndex
|
||||
newEdge.Attributes.Label = e.Attributes.Label
|
||||
newEdge.References = e.References
|
||||
}
|
||||
|
|
|
|||
|
|
@ -607,8 +607,8 @@ type Edge struct {
|
|||
MinWidth int `json:"minWidth"`
|
||||
MinHeight int `json:"minHeight"`
|
||||
|
||||
FromTableRowIndex int `json:"fromTableRowIndex"`
|
||||
ToTableRowIndex int `json:"toTableRowIndex"`
|
||||
FromTableColumnIndex *int `json:"fromTableColumnIndex,omitempty"`
|
||||
ToTableColumnIndex *int `json:"toTableColumnIndex,omitempty"`
|
||||
|
||||
LabelDimensions d2target.TextDimensions `json:"label_dimensions"`
|
||||
LabelPosition *string `json:"labelPosition,omitempty"`
|
||||
|
|
|
|||
|
|
@ -831,6 +831,44 @@ a -> md -> b
|
|||
+setTimeout(seconds int)
|
||||
}
|
||||
`,
|
||||
}, {
|
||||
name: "sql_tables",
|
||||
script: `
|
||||
users: {
|
||||
shape: sql_table
|
||||
id: int
|
||||
name: string
|
||||
email: string
|
||||
password: string
|
||||
last_login: datetime
|
||||
}
|
||||
|
||||
products: {
|
||||
shape: sql_table
|
||||
id: int
|
||||
price: decimal
|
||||
sku: string
|
||||
name: string
|
||||
}
|
||||
|
||||
orders: {
|
||||
shape: sql_table
|
||||
id: int
|
||||
user_id: int
|
||||
product_id: int
|
||||
}
|
||||
|
||||
shipments: {
|
||||
shape: sql_table
|
||||
id: int
|
||||
order_id: int
|
||||
tracking_number: string
|
||||
status: string
|
||||
}
|
||||
|
||||
users.id <-> orders.user_id
|
||||
products.id <-> orders.product_id
|
||||
shipments.order_id <-> orders.id`,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue