mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: add support for referencing fks to existing fields (#1289)
This commit is contained in:
@@ -25,9 +25,8 @@ var (
|
||||
PrimaryKey: []*schema.Column{PetsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "pets_users_pets",
|
||||
Columns: []*schema.Column{PetsColumns[2]},
|
||||
|
||||
Symbol: "pets_users_pets",
|
||||
Columns: []*schema.Column{PetsColumns[2]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
|
||||
@@ -381,7 +381,8 @@ func (pq *PetQuery) sqlAll(ctx context.Context) ([]*Pet, error) {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Pet)
|
||||
for i := range nodes {
|
||||
if fk := nodes[i].user_pets; fk != nil {
|
||||
fk := nodes[i].user_pets
|
||||
if fk != nil {
|
||||
ids = append(ids, *fk)
|
||||
nodeids[*fk] = append(nodeids[*fk], nodes[i])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user