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

Function extractNameListParts

backend/plugin/parser/pg/resource_change.go:282–299  ·  view source on GitHub ↗

extractNameListParts extracts db, schema, name from a list of String nodes.

(nameList *ast.List, defaultDB string)

Source from the content-addressed store, hash-verified

280
281// extractNameListParts extracts db, schema, name from a list of String nodes.
282func extractNameListParts(nameList *ast.List, defaultDB string) (string, string, string) {
283 var parts []string
284 for _, item := range nameList.Items {
285 if s, ok := item.(*ast.String); ok {
286 parts = append(parts, s.Str)
287 }
288 }
289 switch len(parts) {
290 case 1:
291 return defaultDB, "", parts[0]
292 case 2:
293 return defaultDB, parts[0], parts[1]
294 case 3:
295 return parts[0], parts[1], parts[2]
296 default:
297 return defaultDB, "", ""
298 }
299}
300
301// getOmniStatementText returns the text of a statement from OmniAST, including semicolon.
302func getOmniStatementText(omniAST *OmniAST) string {

Callers 2

handleDropTableOmniFunction · 0.85
handleDropIndexOmniFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected