Current Behavior 😯
func (User) Fields() []ent.Field {
return []ent.Field{
field.UUID("id", uuid.UUID{}).
Unique().
Immutable().
Default(uuid.New). // This works
Annotations(entproto.Field(1)),
field.String("name").
DefaultFunc(randstr). // This not work.
Annotations(entproto.Field(2)),
field.Time("created_at").
Immutable().
Default(time.Now). // This not work.
Annotations(entproto.Field(2)),
}
}
This happens because generated code (func (x *XService) createBuilder) calls m.SetXXX(v) even if v is the zero value.
Expected Behavior 🤔
Fucntion given by DefaultFunc or Default must be invoked and the result must be set as a field value.
Steps to Reproduce 🕹
Steps:
- Genreate gRPC services with Create RPC.
- Call Create.
Your Environment 🌎
| Tech |
Version |
| Go |
1.22.3 |
| Ent |
0.12.5 |
| Database |
sliqte3 |
| Driver |
mem |
Current Behavior 😯
This happens because generated code (
func (x *XService) createBuilder) callsm.SetXXX(v)even ifvis the zero value.Expected Behavior 🤔
Fucntion given by
DefaultFuncorDefaultmust be invoked and the result must be set as a field value.Steps to Reproduce 🕹
Steps:
Your Environment 🌎