Allow selection of all columns in a leaf preload by not specifying any column
This commit is contained in:
parent
17358d66b6
commit
89a266addf
|
@ -98,6 +98,10 @@ func (statement *Statement) genColumnStr() string {
|
|||
continue
|
||||
}
|
||||
|
||||
if col.Association != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if buf.Len() != 0 {
|
||||
buf.WriteString(", ")
|
||||
}
|
||||
|
|
|
@ -134,9 +134,14 @@ func (node *PreloadTreeNode) compute(session *Session, ownMap, pruneMap reflect.
|
|||
}
|
||||
|
||||
refMap := node.association.MakeRefMap()
|
||||
preloadSession := session.Engine().Cols(node.extraCols...).Where(cond)
|
||||
preloadSession := session.Engine().Where(cond)
|
||||
if node.preload != nil {
|
||||
preloadSession.Cols(node.preload.cols...).Where(node.preload.cond)
|
||||
if len(node.preload.cols) > 0 {
|
||||
preloadSession.Cols(node.extraCols...).Cols(node.preload.cols...)
|
||||
}
|
||||
preloadSession.Where(node.preload.cond)
|
||||
} else {
|
||||
preloadSession.Cols(node.extraCols...)
|
||||
}
|
||||
if err := preloadSession.Find(refMap.Interface()); err != nil {
|
||||
return err
|
||||
|
|
|
@ -124,10 +124,12 @@ insert into employee_indication values (1,2), (1,3), (2,3), (2,4), (2,5), (3,5),
|
|||
Subordinates: []*Employee{
|
||||
{
|
||||
Id: 3,
|
||||
Name: "Alice",
|
||||
ManagerId: &[]int64{1}[0],
|
||||
IndicatedBy: []*Employee{
|
||||
{
|
||||
Id: 1,
|
||||
Id: 1,
|
||||
Name: "John",
|
||||
Indications: []*Employee{
|
||||
{
|
||||
Id: 2,
|
||||
|
|
Loading…
Reference in New Issue