-
Notifications
You must be signed in to change notification settings - Fork 14
/
savepoint.go
37 lines (27 loc) · 893 Bytes
/
savepoint.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package sql
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock
import "fmt"
// This file copies an interface from https://github.com/DATA-DOG/go-txdb
// SavePoint defines the syntax to create savepoints
// within transaction.
type SavePoint interface {
Create(id string) string
Release(id string) string
Rollback(id string) string
}
//revive:disable:exported
type DefaultSavePoint struct{}
// NewSavePoint is an implementation of trm.SavePoint.
func NewSavePoint() DefaultSavePoint {
return DefaultSavePoint{}
}
func (dsp DefaultSavePoint) Create(id string) string {
return fmt.Sprintf("SAVEPOINT %s", id)
}
func (dsp DefaultSavePoint) Release(id string) string {
return fmt.Sprintf("RELEASE SAVEPOINT %s", id)
}
func (dsp DefaultSavePoint) Rollback(id string) string {
return fmt.Sprintf("ROLLBACK TO SAVEPOINT %s", id)
}
//revive:enabled:exported