mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
entc/gen: filter duplicate ids when loading m2m edges
This commit is contained in:
committed by
Ariel Mashraki
parent
6ab0d01ea4
commit
e92dfee33f
@@ -391,7 +391,6 @@ func (gq *GroupQuery) sqlAll(ctx context.Context) ([]*Group, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(group.UsersPrimaryKey[0], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -410,7 +409,9 @@ func (gq *GroupQuery) sqlAll(ctx context.Context) ([]*Group, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -391,7 +391,6 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(user.GroupsPrimaryKey[1], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -410,7 +409,9 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -390,7 +390,6 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(user.FriendsPrimaryKey[0], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -409,7 +408,9 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -426,7 +426,6 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(user.FollowersPrimaryKey[1], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -445,7 +444,9 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
@@ -490,7 +491,6 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(user.FollowingPrimaryKey[0], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -509,7 +509,9 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -471,7 +471,6 @@ func (gq *GroupQuery) sqlAll(ctx context.Context) ([]*Group, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(group.UsersPrimaryKey[1], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -490,7 +489,9 @@ func (gq *GroupQuery) sqlAll(ctx context.Context) ([]*Group, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -471,7 +471,6 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(user.GroupsPrimaryKey[0], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -490,7 +489,9 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -391,7 +391,6 @@ func (gq *GroupQuery) sqlAll(ctx context.Context) ([]*Group, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(group.UsersPrimaryKey[0], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -410,7 +409,9 @@ func (gq *GroupQuery) sqlAll(ctx context.Context) ([]*Group, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -457,7 +457,6 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(user.GroupsPrimaryKey[1], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -476,7 +475,9 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -435,7 +435,6 @@ func (gq *GroupQuery) sqlAll(ctx context.Context) ([]*Group, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(group.UsersPrimaryKey[0], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -454,7 +453,9 @@ func (gq *GroupQuery) sqlAll(ctx context.Context) ([]*Group, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -435,7 +435,6 @@ func (pq *PetQuery) sqlAll(ctx context.Context) ([]*Pet, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(pet.FriendsPrimaryKey[0], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -454,7 +453,9 @@ func (pq *PetQuery) sqlAll(ctx context.Context) ([]*Pet, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -529,7 +529,6 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(user.FriendsPrimaryKey[0], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -548,7 +547,9 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
@@ -593,7 +594,6 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
Predicate: func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(user.GroupsPrimaryKey[1], fks...))
|
||||
},
|
||||
|
||||
ScanValues: func() [2]interface{} {
|
||||
return [2]interface{}{&sql.NullInt64{}, &sql.NullInt64{}}
|
||||
},
|
||||
@@ -612,7 +612,9 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected node id in edges: %v", outValue)
|
||||
}
|
||||
edgeids = append(edgeids, inValue)
|
||||
if _, ok := edges[inValue]; !ok {
|
||||
edgeids = append(edgeids, inValue)
|
||||
}
|
||||
edges[inValue] = append(edges[inValue], node)
|
||||
return nil
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user