MCPcopy Create free account
hub / github.com/bytebase/bytebase / parsePGSearchPathItem

Function parsePGSearchPathItem

backend/store/model/pg_search_path.go:65–90  ·  view source on GitHub ↗
(token string)

Source from the content-addressed store, hash-verified

63}
64
65func parsePGSearchPathItem(token string) (PGSearchPathItem, bool) {
66 token = strings.TrimSpace(token)
67 if token == "" {
68 return PGSearchPathItem{}, false
69 }
70
71 schema := strings.ToLower(token)
72 switch {
73 case len(token) >= 2 && token[0] == '"' && token[len(token)-1] == '"':
74 schema = strings.ReplaceAll(token[1:len(token)-1], `""`, `"`)
75 case len(token) >= 2 && token[0] == '\'' && token[len(token)-1] == '\'':
76 schema = strings.ReplaceAll(token[1:len(token)-1], `''`, `'`)
77 default:
78 }
79
80 if schema == "$user" {
81 return PGSearchPathItem{CurrentUser: true}, true
82 }
83 if isPGSystemPath(schema) {
84 return PGSearchPathItem{}, false
85 }
86 if schema == "" {
87 return PGSearchPathItem{}, false
88 }
89 return PGSearchPathItem{Schema: schema}, true
90}
91
92func splitPGSearchPath(searchPath string) []string {
93 var parts []string

Callers 1

Calls 1

isPGSystemPathFunction · 0.85

Tested by

no test coverage detected