Correct caching for upserts with no returns
- Previously it would return early, and therefore no caching was being performed since it would never write to the cache.
This commit is contained in:
parent
440e3a1343
commit
bac82b6f0e
1 changed files with 7 additions and 7 deletions
|
@ -131,20 +131,17 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if ne .DriverName
|
|||
return errors.Wrap(err, "{{.PkgName}}: unable to upsert for {{.Table.Name}}")
|
||||
}
|
||||
|
||||
var lastID int64
|
||||
var identifierCols []interface{}
|
||||
if len(cache.retMapping) == 0 {
|
||||
{{if not .NoHooks -}}
|
||||
return o.doAfterUpsertHooks(exec)
|
||||
{{else -}}
|
||||
return nil
|
||||
{{end -}}
|
||||
goto CacheNoHooks
|
||||
}
|
||||
|
||||
lastID, err := result.LastInsertId()
|
||||
lastID, err = result.LastInsertId()
|
||||
if err != nil {
|
||||
return ErrSyncFail
|
||||
}
|
||||
|
||||
var identifierCols []interface{}
|
||||
if lastID != 0 {
|
||||
{{- $colName := index .Table.PKey.Columns 0 -}}
|
||||
{{- $col := .Table.GetColumn $colName -}}
|
||||
|
@ -180,6 +177,9 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if ne .DriverName
|
|||
}
|
||||
{{- end}}
|
||||
|
||||
{{if .UseLastInsertID -}}
|
||||
CacheNoHooks:
|
||||
{{end -}}
|
||||
if !cached {
|
||||
{{$varNameSingular}}UpsertCacheMut.Lock()
|
||||
{{$varNameSingular}}UpsertCache[key] = cache
|
||||
|
|
Loading…
Add table
Reference in a new issue