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}}")
|
return errors.Wrap(err, "{{.PkgName}}: unable to upsert for {{.Table.Name}}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lastID int64
|
||||||
|
var identifierCols []interface{}
|
||||||
if len(cache.retMapping) == 0 {
|
if len(cache.retMapping) == 0 {
|
||||||
{{if not .NoHooks -}}
|
goto CacheNoHooks
|
||||||
return o.doAfterUpsertHooks(exec)
|
|
||||||
{{else -}}
|
|
||||||
return nil
|
|
||||||
{{end -}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastID, err := result.LastInsertId()
|
lastID, err = result.LastInsertId()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrSyncFail
|
return ErrSyncFail
|
||||||
}
|
}
|
||||||
|
|
||||||
var identifierCols []interface{}
|
|
||||||
if lastID != 0 {
|
if lastID != 0 {
|
||||||
{{- $colName := index .Table.PKey.Columns 0 -}}
|
{{- $colName := index .Table.PKey.Columns 0 -}}
|
||||||
{{- $col := .Table.GetColumn $colName -}}
|
{{- $col := .Table.GetColumn $colName -}}
|
||||||
|
@ -180,6 +177,9 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if ne .DriverName
|
||||||
}
|
}
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
|
||||||
|
{{if .UseLastInsertID -}}
|
||||||
|
CacheNoHooks:
|
||||||
|
{{end -}}
|
||||||
if !cached {
|
if !cached {
|
||||||
{{$varNameSingular}}UpsertCacheMut.Lock()
|
{{$varNameSingular}}UpsertCacheMut.Lock()
|
||||||
{{$varNameSingular}}UpsertCache[key] = cache
|
{{$varNameSingular}}UpsertCache[key] = cache
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue