mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
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:
committed by
Ariel Mashraki
parent
89fade53f6
commit
5cb40ff883
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user