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:
@@ -37,9 +37,8 @@ var (
|
||||
PrimaryKey: []*schema.Column{StreetsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "streets_cities_streets",
|
||||
Columns: []*schema.Column{StreetsColumns[2]},
|
||||
|
||||
Symbol: "streets_cities_streets",
|
||||
Columns: []*schema.Column{StreetsColumns[2]},
|
||||
RefColumns: []*schema.Column{CitiesColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
|
||||
@@ -381,7 +381,8 @@ func (sq *StreetQuery) sqlAll(ctx context.Context) ([]*Street, error) {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Street)
|
||||
for i := range nodes {
|
||||
if fk := nodes[i].city_streets; fk != nil {
|
||||
fk := nodes[i].city_streets
|
||||
if fk != nil {
|
||||
ids = append(ids, *fk)
|
||||
nodeids[*fk] = append(nodeids[*fk], nodes[i])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user