mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: ignore edge-fields order in edge-schema with composite identifiers (#2719)
This PR allows defining edge schemas with any order of their edges but still enforce the ordering of the fields in the ID annotation
This commit is contained in:
@@ -69,10 +69,25 @@ func (t *Table) AddColumn(c *Column) *Table {
|
||||
|
||||
// HasColumn reports if the table contains a column with the given name.
|
||||
func (t *Table) HasColumn(name string) bool {
|
||||
_, ok := t.columns[name]
|
||||
_, ok := t.Column(name)
|
||||
return ok
|
||||
}
|
||||
|
||||
// Column returns the column with the given name. If exists.
|
||||
func (t *Table) Column(name string) (*Column, bool) {
|
||||
if c, ok := t.columns[name]; ok {
|
||||
return c, true
|
||||
}
|
||||
// In case the column was added
|
||||
// directly to the Columns field.
|
||||
for _, c := range t.Columns {
|
||||
if c.Name == name {
|
||||
return c, true
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// SetAnnotation the entsql.Annotation on the table.
|
||||
func (t *Table) SetAnnotation(ant *entsql.Annotation) *Table {
|
||||
t.Annotation = ant
|
||||
|
||||
Reference in New Issue
Block a user