From 754b56856a73237870f6258689e5ca9e29791caf Mon Sep 17 00:00:00 2001 From: Ariel Mashraki Date: Wed, 16 Jun 2021 22:12:23 +0300 Subject: [PATCH] entc/gen: disallow immutable edge-fields Until we add the immutable option for edges --- entc/gen/type.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/entc/gen/type.go b/entc/gen/type.go index 06cd270aa..f3041337d 100644 --- a/entc/gen/type.go +++ b/entc/gen/type.go @@ -646,6 +646,9 @@ func (t *Type) setupFieldEdge(fk *ForeignKey, fkOwner *Edge, fkName string) erro if tf.Optional != fkOwner.Optional { return fmt.Errorf("mismatch optional/required config for edge %q and field %q", fkOwner.Name, fkName) } + if tf.Immutable { + return fmt.Errorf("field edge %q cannot be immutable", fkName) + } if t1, t2 := tf.Type.Type, fkOwner.Type.ID.Type.Type; t1 != t2 { return fmt.Errorf("mismatch field type between edge field %q and id of type %q (%s != %s)", fkName, fkOwner.Type.Name, t1, t2) }