focalboard/server/services/store/generators/transactional_store.go.tmpl
Doug Lauder a47baf7f23
Multi version archive import (#2220)
* Fixed panic in PropDef.GetValue for `person` property types.
- the GetUserByID API can return a nil user and nil error

* return userid

* support old archive format

* move template init to app layer

* move app init

* init app

* revert

* ignore GetDefaultTemplate blocks call in store mock

* ignore GetDefaultTemplate blocks call in store mock2

* ignore InsertBlockss call in store mock3

* ignore RemoveDefaultTemplates call in store mock4

* ignore WriteFile call in files mock5

* ignore WriteFile call in files mock6

* ignore WriteFile call in files mock7

* ignore WriteFile call in files mock8

* fix unit tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-02-02 11:25:06 -07:00

59 lines
2.1 KiB
Cheetah

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// Code generated by "make generate" from the Store interface
// DO NOT EDIT
// To add a public method, create an entry in the Store interface,
// prefix it with a @withTransaction comment if you need it to be
// transactional and then add a private method in the store itself
// with db sq.BaseRunner as the first parameter before running `make
// generate`
package sqlstore
import (
"context"
"time"
"github.com/mattermost/focalboard/server/model"
"github.com/mattermost/focalboard/server/services/store"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
)
{{range $index, $element := .Methods}}
func (s *SQLStore) {{$index}}({{$element.Params | joinParamsWithType}}) {{$element.Results | joinResultsForSignature}} {
{{- if $element.WithTransaction}}
tx, txErr := s.db.BeginTx(context.Background(), nil)
if txErr != nil {
return {{ genErrorResultsVars $element.Results "txErr"}}
}
{{- if $element.Results | len | eq 0}}
s.{{$index | renameStoreMethod}}(tx, {{$element.Params | joinParams}})
if err := tx.Commit(); err != nil {
return {{ genErrorResultsVars $element.Results "err"}}
}
{{else}}
{{genResultsVars $element.Results false }} := s.{{$index | renameStoreMethod}}(tx, {{$element.Params | joinParams}})
{{- if $element.Results | errorPresent }}
if {{$element.Results | errorVar}} != nil {
if rollbackErr := tx.Rollback(); rollbackErr != nil {
s.logger.Error("transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "{{$index}}"))
}
return {{ genErrorResultsVars $element.Results "err"}}
}
{{end}}
if err := tx.Commit(); err != nil {
return {{ genErrorResultsVars $element.Results "err"}}
}
return {{ genResultsVars $element.Results true -}}
{{end}}
{{else}}
return s.{{$index | renameStoreMethod}}(s.db, {{$element.Params | joinParams}})
{{end}}
}
{{end}}