aboutsummaryrefslogtreecommitdiff
path: root/src/database/sql/sql.go
diff options
context:
space:
mode:
authorAlexey Palazhchenko <alexey.palazhchenko@gmail.com>2018-02-06 08:56:53 +0300
committerDaniel Theophanes <kardianos@gmail.com>2018-02-22 15:17:52 +0000
commitef3ab3f5e2e612532733b3cdd38eefa387595fe3 (patch)
treeaee728a2770cc19702fa24db65c0ce3c5832cd03 /src/database/sql/sql.go
parent1e05924cf53c3cfe84114f4bf7a31b8632fdc608 (diff)
downloadgo-ef3ab3f5e2e612532733b3cdd38eefa387595fe3.tar.xz
database/sql: add String method to IsolationLevel
Fixes #23632 Change-Id: I7197e13df6cf28400a6dd86c110f41129550abb6 Reviewed-on: https://go-review.googlesource.com/92235 Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Diffstat (limited to 'src/database/sql/sql.go')
-rw-r--r--src/database/sql/sql.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go
index 5956d6ad46..24e906938e 100644
--- a/src/database/sql/sql.go
+++ b/src/database/sql/sql.go
@@ -24,6 +24,7 @@ import (
"reflect"
"runtime"
"sort"
+ "strconv"
"sync"
"sync/atomic"
"time"
@@ -132,6 +133,31 @@ const (
LevelLinearizable
)
+func (i IsolationLevel) String() string {
+ switch i {
+ case LevelDefault:
+ return "Default"
+ case LevelReadUncommitted:
+ return "Read Uncommitted"
+ case LevelReadCommitted:
+ return "Read Committed"
+ case LevelWriteCommitted:
+ return "Write Committed"
+ case LevelRepeatableRead:
+ return "Repeatable Read"
+ case LevelSnapshot:
+ return "Snapshot"
+ case LevelSerializable:
+ return "Serializable"
+ case LevelLinearizable:
+ return "Linearizable"
+ default:
+ return "IsolationLevel(" + strconv.Itoa(int(i)) + ")"
+ }
+}
+
+var _ fmt.Stringer = LevelDefault
+
// TxOptions holds the transaction options to be used in DB.BeginTx.
type TxOptions struct {
// Isolation is the transaction isolation level.