entc/gen: reject codegen in case of duplicate edges (#858)

See #856
This commit is contained in:
Ariel Mashraki
2020-10-16 14:04:52 +03:00
committed by GitHub
parent 2128d0baee
commit 7635d45c8a
3 changed files with 26 additions and 3 deletions

View File

@@ -239,11 +239,11 @@ func (t Type) Receiver() string {
return receiver(t.Name)
}
// HasAssoc returns true if this type has an assoc edge with the given name.
// faster than map access for most cases.
// HasAssoc returns true if this type has an assoc-edge (non-inverse)
// with the given name. faster than map access for most cases.
func (t Type) HasAssoc(name string) (*Edge, bool) {
for _, e := range t.Edges {
if name == e.Name {
if name == e.Name && !e.IsInverse() {
return e, true
}
}