entc/gen/eagerloading: ignore loading edges on empty result (#298)

* fix eagerloading

while parent nodes is zero.

* Update entc/gen/template/dialect/sql/query.tmpl

Co-Authored-By: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* Update entc/gen/template/dialect/sql/query.tmpl

Co-Authored-By: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* generate new assets

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
This commit is contained in:
Harold.Luo
2020-01-20 22:29:01 +08:00
committed by Ariel Mashraki
parent 89fade53f6
commit 5cb40ff883
49 changed files with 194 additions and 3 deletions

View File

@@ -324,6 +324,10 @@ func (cq *CarQuery) sqlAll(ctx context.Context) ([]*Car, error) {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := cq.withOwner; query != nil {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Car)

View File

@@ -314,6 +314,10 @@ func (gq *GroupQuery) sqlAll(ctx context.Context) ([]*Group, error) {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := gq.withUsers; query != nil {
fks := make([]driver.Value, 0, len(nodes))
ids := make(map[int]*Group, len(nodes))

View File

@@ -339,6 +339,10 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := uq.withCars; query != nil {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*User)