entc/gen: skip executing sub-query for empty set of edges (#3212)

This commit is contained in:
Ariel Mashraki
2023-01-07 08:54:18 +02:00
committed by GitHub
parent b7da6253b6
commit b88f45aa78
64 changed files with 251 additions and 2 deletions

View File

@@ -417,6 +417,9 @@ func (cq *CardQuery) loadOwner(ctx context.Context, query *UserQuery, nodes []*C
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(user.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {

View File

@@ -460,6 +460,9 @@ func (pq *PetQuery) loadBestFriend(ctx context.Context, query *PetQuery, nodes [
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(pet.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
@@ -486,6 +489,9 @@ func (pq *PetQuery) loadOwner(ctx context.Context, query *UserQuery, nodes []*Pe
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(user.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {