Open
Description
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Assume Person
has immutable edge to Pet
(e.g. Person
is owner of Pet
).
Code for PetService.Update
is generated as follow:
if pet.GetOwner() != nil {
petOwner := int(pet.GetOwner().GetId())
m.SetOwnerID(petOwner) // <- SetOwnerID undefined since the edge is immutable.
}
Expected Behavior 🤔
The code if pet.GetOwner() != nil { ... }
should not be generated.
Steps to Reproduce 🕹
// Edges of the Person.
func (Person) Edges() []ent.Edge {
return []ent.Edge{
edge.To("pets", Pet.Type).
Annotations(entproto.Field(2)),
}
}
// Edges of the Pet.
func (Pet) Edges() []ent.Edge {
return []ent.Edge{
edge.From("owner", Person.Type).Ref("pets").Immutable().Unique().Required().
Annotations(entproto.Field(2)),
}
}
Your Environment 🌎
Tech | Version |
---|---|
Go | go1.21.4 linux/amd64 |
Ent | v0.12.5 |
Database | N/A |
Driver | N/A |
entgo.io/contrib | v0.4.6-0.20231111095018-6ed0397cd307 |
Metadata
Metadata
Assignees
Labels
No labels