[#586] fixed nested multiple expands with shared path

This commit is contained in:
Gani Georgiev
2022-12-20 11:07:16 +02:00
parent ca528cef03
commit fb57c8091d
34 changed files with 216 additions and 41 deletions
+1 -6
View File
@@ -216,12 +216,7 @@ func (dao *Dao) expandRecords(records []*models.Record, expandPath string, fetch
continue
}
oldRelExpand := oldExpandedRel.Expand()
newRelExpand := rel.Expand()
for k, v := range oldRelExpand {
newRelExpand[k] = v
}
rel.SetExpand(newRelExpand)
rel.MergeExpand(oldExpandedRel.Expand())
}
}
+16
View File
@@ -167,6 +167,22 @@ func TestExpandRecords(t *testing.T) {
5,
0,
},
{
"expand multiple relations sharing a common path",
"demo4",
[]string{"qzaqccwrmva4o1n"},
[]string{
"rel_one_no_cascade",
"rel_many_no_cascade",
"self_rel_many.self_rel_one.rel_many_cascade",
"self_rel_many.self_rel_one.rel_many_no_cascade_required",
},
func(c *models.Collection, ids []string) ([]*models.Record, error) {
return app.Dao().FindRecordsByIds(c.Id, ids, nil)
},
5,
0,
},
}
for _, s := range scenarios {