entc/gen: initial support for user-defined ids

Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/162

Reviewed By: alexsn

Differential Revision: D18485086

fbshipit-source-id: 9bb6ccff592bc0cb8b218625161ed492f67bc170
This commit is contained in:
Ariel Mashraki
2019-11-14 08:19:54 -08:00
committed by Facebook Github Bot
parent e161ecc29c
commit d9da7243f9
33 changed files with 3748 additions and 26 deletions

View File

@@ -331,8 +331,9 @@ func (g *Graph) Tables() (all []*schema.Table) {
})
case M2M:
t1, t2 := tables[n.Table()], tables[e.Type.Table()]
c1 := &schema.Column{Name: e.Rel.Columns[0], Type: field.TypeInt}
c2 := &schema.Column{Name: e.Rel.Columns[1], Type: field.TypeInt}
fk1, fk2 := n.ID, e.Type.ID
c1 := &schema.Column{Name: e.Rel.Columns[0], Type: fk1.Type.Type}
c2 := &schema.Column{Name: e.Rel.Columns[1], Type: fk2.Type.Type}
all = append(all, &schema.Table{
Name: e.Rel.Table,
Columns: []*schema.Column{c1, c2},