From: Alexey Palazhchenko Date: Tue, 6 Feb 2018 05:56:53 +0000 (+0300) Subject: database/sql: add String method to IsolationLevel X-Git-Tag: go1.11beta1~1489 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ef3ab3f5e2e612532733b3cdd38eefa387595fe3;p=gostls13.git database/sql: add String method to IsolationLevel Fixes #23632 Change-Id: I7197e13df6cf28400a6dd86c110f41129550abb6 Reviewed-on: https://go-review.googlesource.com/92235 Reviewed-by: Daniel Theophanes --- 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.