github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/xsql/mode.go (about) 1 package xsql 2 3 import "fmt" 4 5 type QueryMode int 6 7 const ( 8 UnknownQueryMode = QueryMode(iota) 9 DataQueryMode 10 ExplainQueryMode 11 ScanQueryMode 12 SchemeQueryMode 13 ScriptingQueryMode 14 15 DefaultQueryMode = DataQueryMode 16 ) 17 18 var ( 19 typeToString = map[QueryMode]string{ 20 DataQueryMode: "data", 21 ScanQueryMode: "scan", 22 ExplainQueryMode: "explain", 23 SchemeQueryMode: "scheme", 24 ScriptingQueryMode: "scripting", 25 } 26 stringToType = map[string]QueryMode{ 27 "data": DataQueryMode, 28 "scan": ScanQueryMode, 29 "explain": ExplainQueryMode, 30 "scheme": SchemeQueryMode, 31 "scripting": ScriptingQueryMode, 32 } 33 ) 34 35 func (t QueryMode) String() string { 36 if s, ok := typeToString[t]; ok { 37 return s 38 } 39 40 return fmt.Sprintf("unknown_mode_%d", t) 41 } 42 43 func QueryModeFromString(s string) QueryMode { 44 if t, ok := stringToType[s]; ok { 45 return t 46 } 47 48 return UnknownQueryMode 49 }