I'm struggling with inserting some rows into my SQLite DB. I'm using SQLBoiler as my ORM library.
when I'm trying to execute the following code:
//CreateWeeklyForecastReport create a full week forecast report
func CreateWeeklyForecastReport(mock *dm.ForecastMock, storeNumber int, isDefault bool) (*models.FORECASTWEEKLY, error) {
res := createNewForecastWeekly(storeNumber, isDefault)
if err := res.Insert(context.Background(), DB, boil.Infer()); err != nil {
return nil, err
}
ordersByDays := groupOrdersByDates(mock.DBData.OrdersTimes)
for day, orderTime := range ordersByDays {
daily := models.FORECASTDAILY{DATE: day, FORECASTWEEKLYS: res.FORECASTWID}
if err := daily.Insert(context.Background(), DB, boil.Infer()); err != nil {
return nil, err
}
mock.DBData.OrdersTimes = orderTime
res := ForecastDaily(mock)
for _, hr := range res {
hourRes := hr.ToForecastHourly(daily.FORECASTDID)
//CODE FAILS HERE
if err := hourRes.Insert(context.Background(), DB, boil.Infer()); err != nil {
return nil, err
}
}
}
return &res, nil
}
all of the inserts are working perfectly except for the last one. at the last insert:
if err := hourRes.Insert(context.Background(), DB, boil.Infer()); err != nil {
return nil, err
}
and I'm getting the following error:
2019-08-27T22:50:55.387+0300 ERROR infra/LogUtils.go:73 failed to create custom forecast report {"error": "models: unable to populate default values for FORECAST_HOURLY: sql: no rows in result set", "errorVerbose": "sql: no rows in result set
models: unable to populate default values for FORECAST_HOURLY
bitbucket.org/dragontailcom/analysis/models.
the funny part is that the row is actually inserted into the DB.
any ideas?