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:
@@ -381,7 +381,8 @@ func (cq *CardQuery) sqlAll(ctx context.Context) ([]*Card, error) {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Card)
|
||||
for i := range nodes {
|
||||
if fk := nodes[i].user_card; fk != nil {
|
||||
fk := nodes[i].user_card
|
||||
if fk != nil {
|
||||
ids = append(ids, *fk)
|
||||
nodeids[*fk] = append(nodeids[*fk], nodes[i])
|
||||
}
|
||||
|
||||
@@ -26,9 +26,8 @@ var (
|
||||
PrimaryKey: []*schema.Column{CardsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "cards_users_card",
|
||||
Columns: []*schema.Column{CardsColumns[3]},
|
||||
|
||||
Symbol: "cards_users_card",
|
||||
Columns: []*schema.Column{CardsColumns[3]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user