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
@@ -349,6 +349,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))
|
||||
|
||||
@@ -349,6 +349,10 @@ func (pq *PetQuery) sqlAll(ctx context.Context) ([]*Pet, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
if query := pq.withFriends; query != nil {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
ids := make(map[int]*Pet, len(nodes))
|
||||
|
||||
@@ -387,6 +387,10 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
if query := uq.withPets; query != nil {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*User)
|
||||
|
||||
Reference in New Issue
Block a user