3
0

Fix report frame builder lapsus with ref columns

This commit is contained in:
Tomaž Jerman 2022-09-27 12:12:52 +02:00
parent 730621a9f7
commit 2b0a1640d1
2 changed files with 11 additions and 9 deletions

View File

@ -14,8 +14,9 @@ type (
// Primarily simplifies mapping the correct iterator attributes to correct
// frame row columns and having them encoded properly.
reportFrameBuilder struct {
def *FrameDefinition
frame *Frame
def *FrameDefinition
frame *Frame
ownCol string
attrMapping map[string]int
attrMvDel map[string]string
@ -49,9 +50,10 @@ func newReportFrameBuilder(def *FrameDefinition) *reportFrameBuilder {
}
// linked includes additional metadata required by the link step
func (b *reportFrameBuilder) linked(col, src string) {
b.frame.RelColumn = col
b.frame.RelSource = src
func (b *reportFrameBuilder) linked(ownCol, relCol, relSrc string) {
b.ownCol = ownCol
b.frame.RelColumn = relCol
b.frame.RelSource = relSrc
}
// addRow adds a new dal.Row to the frame
@ -74,9 +76,9 @@ func (b *reportFrameBuilder) addRow(r *dal.Row) {
b.frame.Rows = append(b.frame.Rows, rrow)
if b.frame.RelColumn != "" {
v, _ := r.GetValue(b.frame.RelColumn, 0)
b.frame.RefValue = b.stringifyVal(b.frame.RelColumn, v)
if b.ownCol != "" {
v, _ := r.GetValue(b.ownCol, 0)
b.frame.RefValue = b.stringifyVal(b.ownCol, v)
}
}

View File

@ -139,7 +139,7 @@ func stepLinkFrames(ctx context.Context, iter dal.Iterator, r run) (ff []*Frame,
builders := make(map[bool]*reportFrameBuilder)
builders[true] = newReportFrameBuilder(defLeft)
builders[false] = newReportFrameBuilder(defRight)
builders[false].linked(defLink.On.Right, defLink.RelLeft)
builders[false].linked(defLink.On.Right, defLink.On.Left, defLink.RelLeft)
limits := make(map[bool]uint)
if defLeft.Paging != nil {