mirror of
https://github.com/ent/ent.git
synced 2026-05-28 09:49:08 +03:00
entc/gen: change eager-loading empty values (#791)
When loading relations (using edger-loading) and there are no changes, the response should be an empty slice (and not nil). Similar to the way we handle simple queries (e.g. All()). Closed #790
This commit is contained in:
@@ -369,6 +369,7 @@ func (gq *GroupQuery) sqlAll(ctx context.Context) ([]*Group, error) {
|
||||
for _, node := range nodes {
|
||||
ids[node.ID] = node
|
||||
fks = append(fks, node.ID)
|
||||
node.Edges.Users = []*User{}
|
||||
}
|
||||
var (
|
||||
edgeids []int
|
||||
|
||||
@@ -405,6 +405,7 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
nodes[i].Edges.Cars = []*Car{}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.Car(func(s *sql.Selector) {
|
||||
@@ -433,6 +434,7 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
for _, node := range nodes {
|
||||
ids[node.ID] = node
|
||||
fks = append(fks, node.ID)
|
||||
node.Edges.Groups = []*Group{}
|
||||
}
|
||||
var (
|
||||
edgeids []int
|
||||
|
||||
Reference in New Issue
Block a user