-
Notifications
You must be signed in to change notification settings - Fork 73
Open
Labels
Description
Consider the following code:
package audit
type Message struct {
ID string `reform:"id,pk"`
Method string `reform:"method"`
Payload interface{}
body []byte `reform:"body"`
}
func (m *Message) BeforeInsert() error {
b, err := json.Marshal(m.Payload)
m.body = b
return err
}An external user of that package can set Payload, but it is always stored in serialized form.
Currently, it is not possible due to check in reform tool: Message has non-exported field body with "reform:" tag, it is not allowed. But we don't have a reason for that check anymore – generated code can access this field directly, no reflection (which almost always works only for exported fields) is required.