I added an entity in my schema which is just a history table to record which "reporting entity" a user has accessed over time, so the only field is a date stamp.
func (ReportingEntitySelection) Fields() []ent.Field {
return []ent.Field{
field.Time("selected_at").
Default(time.Now).
Immutable().
Comment("When this selection was made"),
//field.String("comment"),
}
}
When I go generate ./ent I get an error: declared and not used: entity
The error occurs in this function:
func (h *Handler) ReportingEntitySelectionGet(ctx echo.Context, id int) (url.Values, error) {
entity, err := h.client.ReportingEntitySelection.Get(ctx.Request().Context(), id)
if err != nil {
return nil, err
}
v := url.Values{}
return v, err
}
If I add a field (commented out above field.String("comment"), then the generated function works fine because entity is used in the v.Set statement.
func (h *Handler) ReportingEntitySelectionGet(ctx echo.Context, id int) (url.Values, error) {
entity, err := h.client.ReportingEntitySelection.Get(ctx.Request().Context(), id)
if err != nil {
return nil, err
}
v := url.Values{}
v.Set("comment", entity.Comment)
return v, err
}
Is anyone able to recreate this issue?
I added an entity in my schema which is just a history table to record which "reporting entity" a user has accessed over time, so the only field is a date stamp.
func (ReportingEntitySelection) Fields() []ent.Field {
return []ent.Field{
field.Time("selected_at").
Default(time.Now).
Immutable().
Comment("When this selection was made"),
}
When I go generate ./ent I get an error: declared and not used: entity
The error occurs in this function:
func (h *Handler) ReportingEntitySelectionGet(ctx echo.Context, id int) (url.Values, error) {
entity, err := h.client.ReportingEntitySelection.Get(ctx.Request().Context(), id)
if err != nil {
return nil, err
}
}
If I add a field (commented out above field.String("comment"), then the generated function works fine because entity is used in the v.Set statement.
func (h *Handler) ReportingEntitySelectionGet(ctx echo.Context, id int) (url.Values, error) {
entity, err := h.client.ReportingEntitySelection.Get(ctx.Request().Context(), id)
if err != nil {
return nil, err
}
}
Is anyone able to recreate this issue?