HasOne fails to Preload in the helper.go file
- Dominant language
- Go
- Stars
- 141
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
I have a model with a HasOne relationship like this...
```
Model("Avatar", func() {
Description("Avatar that will display by their name and profile")
Field("id", gorma.Integer, func() {
PrimaryKey()
})
Field("url", gorma.String)
})
Model("User", func() {
Description("User model")
HasOne("Avatar")
HasMany("Files")
```
and it fails to generate a helper function `One[Model](ctx context.Context, id int)` method
```
func (m *UserDB) OneProjectUser(ctx context.Context, id int) (*app.ProjectUser, error) {
defer goa.MeasureSince([]string{"goa", "db", "projectUser", "oneprojectUser"}, time.Now())
var native User
err := m.Db.Scopes().Table(m.TableName()).Preload("Documents").Where("id = ?", id).Find(&native).Error
if err != nil && err != gorm.ErrRecordNotFound {
goa.LogError(ctx, "error getting User", "error", err.Error())
return nil, err
}
view := *native.UserToProjectUser()
return &view, err
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.